Forum: Ruby Ajax woes

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
24c6e4ed08f7a4bf9cfb7edc2dbd14b8?d=identicon&s=25 Patrick Spence (pkspence)
on 2007-02-05 15:56
The C# web app we are automating for QA testing has been recently
converted to Ajax. Because of it's asynchronous nature, this has broken
all our test scripts. In order to get them to work, we resorted to
inserting a "sleep()" statement at the beginning of test method in the
test suite, certainly not an ideal solution. So, in the meantime, we're
stuck with this nonsense:

  def test_0001_username()
    sleep(2)
    @@ie.text_field(:id,'ctl00_lgnLogin_UserName').set('TEST-5038')
  end

  def test_0002_password()
    sleep(2)
    @@ie.text_field(:id,'ctl00_lgnLogin_Password').set('passw0rd')
  end

  def test_0003_loginButton()
    sleep(2)
    @@ie.button(:id,'ctl00_lgnLogin_LoginButton').click
  end

Has anyone else run into this and what was your solution? Thanks!
83ca41657a99b65d99889abe712ba5e2?d=identicon&s=25 Jason Roelofs (Guest)
on 2007-02-05 16:04
(Received via mailing list)
There is a method on @@ie (i'm assuming Watir usage here) called
something
like #wait_for_response that will block until said execution is done.

Jason
24c6e4ed08f7a4bf9cfb7edc2dbd14b8?d=identicon&s=25 Patrick Spence (pkspence)
on 2007-02-05 18:21
Jason Roelofs wrote:
> There is a method on @@ie (i'm assuming Watir usage here) called
> something
> like #wait_for_response that will block until said execution is done.
>
> Jason

I found a #wait method, no #wait_for_response. I tried that and it
didn't help.

On one of the forms, one page of a 13-page health risk assessment,
there's a radiobutton control associated with the question "I know my
blood pressure". If the user clicks "Yes", then 2-more textboxes are
displayed where they enter the systolic and diastolic readings. Without
the "sleep()" statements, the textboxes are skippped, after logging an
error stating that the 2-textboxes couldn't be found. The health risk
assessment was taking about 2.5 mins to complete. With all the sleep()
statements it's now taking about twice that long, as one would expect.
F5e913e74387bb2e1d00826994802021?d=identicon&s=25 alex_f_il@hotmail.com (Guest)
on 2007-02-05 18:55
(Received via mailing list)
On Feb 5, 12:21 pm, Patrick Spence <patr...@pkspence.com> wrote:
> On one of the forms, one page of a 13-page health risk assessment,
> there's a radiobutton control associated with the question "I know my
> blood pressure". If the user clicks "Yes", then 2-more textboxes are
> displayed where they enter the systolic and diastolic readings. Without
> the "sleep()" statements, the textboxes are skippped, after logging an
> error stating that the 2-textboxes couldn't be found. The health risk
> assessment was taking about 2.5 mins to complete. With all the sleep()
> statements it's now taking about twice that long, as one would expect.
>
> --
> Posted viahttp://www.ruby-forum.com/.

I don't think it is possible with current WATIR implementation.
You can also try SWExplorerAutomation SWEA (http:\\webiussoft.com).
SWEA supports AJAX and eleminates "sleep" statements by monitoring
network traffic and DOM changes - it improves the test automation code
reliability and performance. SWEA is .Net framework, but can be used
from Ruby using RubyCLR.
24c6e4ed08f7a4bf9cfb7edc2dbd14b8?d=identicon&s=25 Patrick Spence (pkspence)
on 2007-02-09 15:02
alex_f_il@hotmail.com wrote:
> I don't think it is possible with current WATIR implementation.
> You can also try SWExplorerAutomation SWEA (http:\\webiussoft.com).
> SWEA supports AJAX and eleminates "sleep" statements by monitoring
> network traffic and DOM changes - it improves the test automation code
> reliability and performance. SWEA is .Net framework, but can be used
> from Ruby using RubyCLR.

Thanks for the link, but I was hoping for a Ruby solution. I was
thinking that it's possible to override the
Watir::Element.assert_exists() method. Perhaps go into a loop, on each
iteration of the loop checking @ieController.status for "done" and/or
@ieController.document.readyState == 4. The loop would one run a
specific number of times before exiting and letting Watir throw the
error.

Using the scenario I previously mentioned regarding the blood pressure
radio button and textbox controls... I've noticed that when the "I know
my blood pressure" radio button is clicked, the IE status bar briefly
changes to "Please wait..." while Ajax is doing it's thing. By "doing
it's thing" I mean updating the page to display 2-textbox controls where
the user inputs the systolic and diastolic reading. After the textboxes
are displayed, the status changes back to "Done".

Ideas or hints anyone? Thanks!
68db3bafb0a990bf605c4cf62bf85db0?d=identicon&s=25 Bret Pettichord (Guest)
on 2007-02-11 23:00
(Received via mailing list)
On Feb 5, 8:56 am, Patrick Spence <patr...@pkspence.com> wrote:
>   def test_0001_username()
>     sleep(2)
>     @@ie.text_field(:id,'ctl00_lgnLogin_UserName').set('TEST-5038')
>   end

Actually, the latest version (1.5) of Watir *does* support Ajax. Thus:

   def test_0001_username()
     Watir::wait_until {@@ie.text_field(:id,
'ct100_lgnLogin_UserName').exists?}
     @@ie.text_field(:id,'ctl00_lgnLogin_UserName').set('TEST-5038')
   end

Bret
68db3bafb0a990bf605c4cf62bf85db0?d=identicon&s=25 Bret Pettichord (Guest)
on 2007-02-11 23:01
(Received via mailing list)
On Feb 5, 11:53 am, "alex_f...@hotmail.com" <alex_f...@hotmail.com>
wrote:
> I don't think it is possible with currentWATIRimplementation.

Why do you say this?
24c6e4ed08f7a4bf9cfb7edc2dbd14b8?d=identicon&s=25 Patrick Spence (pkspence)
on 2007-02-12 13:49
Bret Pettichord wrote:
> On Feb 5, 8:56 am, Patrick Spence <patr...@pkspence.com> wrote:
>>   def test_0001_username()
>>     sleep(2)
>>     @@ie.text_field(:id,'ctl00_lgnLogin_UserName').set('TEST-5038')
>>   end
>
> Actually, the latest version (1.5) of Watir *does* support Ajax. Thus:
>
>    def test_0001_username()
>      Watir::wait_until {@@ie.text_field(:id,
> 'ct100_lgnLogin_UserName').exists?}
>      @@ie.text_field(:id,'ctl00_lgnLogin_UserName').set('TEST-5038')
>    end
>
> Bret

Thanks Bret! I'll give this a go, since the waiting for a status of
"Done" approach doesn't appear to be working.
24c6e4ed08f7a4bf9cfb7edc2dbd14b8?d=identicon&s=25 Patrick Spence (pkspence)
on 2007-02-12 14:10
Patrick Spence wrote:
>> Bret Pettichord wrote:
>> Actually, the latest version (1.5) of Watir *does* support Ajax. Thus:
> Thanks Bret! I'll give this a go, since the waiting for a status of
> "Done" approach doesn't appear to be working.
Actually, I'll need to download v1.5. The most current version on
rubyforge.org is 1.4.1. Where can 1.5 be found?

Thanks!
24c6e4ed08f7a4bf9cfb7edc2dbd14b8?d=identicon&s=25 Patrick Spence (pkspence)
on 2007-02-12 14:18
Patrick Spence wrote:
> Actually, I'll need to download v1.5. The most current version on
> rubyforge.org is 1.4.1. Where can 1.5 be found?
>
> Thanks!
I found v1.5.1 at http://www.io.com/~wazmo/blog/, along with suggestion
that those running v1.5 should update to 1.5.1.
151b20c72716eb93ac58fa16fb94ec23?d=identicon&s=25 Bret Pettichord (Guest)
on 2007-02-13 01:37
(Received via mailing list)
On 2/12/07, Patrick Spence <patrick@pkspence.com> wrote:
>
> Actually, I'll need to download v1.5. The most current version on
> rubyforge.org is 1.4.1. Where can 1.5 be found?


http://wiki.openqa.org/display/WTR/Development+Builds

But there seems to be a problem with the gem attachments at the
moment...
24c6e4ed08f7a4bf9cfb7edc2dbd14b8?d=identicon&s=25 Patrick Spence (pkspence)
on 2007-02-13 20:02
Bret Pettichord wrote:
> On 2/12/07, Patrick Spence <patrick@pkspence.com> wrote:
>>
>> Actually, I'll need to download v1.5. The most current version on
>> rubyforge.org is 1.4.1. Where can 1.5 be found?
>
>
> http://wiki.openqa.org/display/WTR/Development+Builds
>
> But there seems to be a problem with the gem attachments at the
> moment...

I don't know if that has anything to do with the problems I'm still
having. The #wait_until technique isn't working either. The decision of
the development folks to convert the app to Ajax was made w/o consulting
the QA department as to the possible ramifications. That, on top of the
other problem has forced us to look at other alternatives to Ruby/Watir.
It's a bloody shame too as we've made a sizable investment in the
development of the core code and classes in Ruby.
151b20c72716eb93ac58fa16fb94ec23?d=identicon&s=25 Bret Pettichord (Guest)
on 2007-02-13 21:33
(Received via mailing list)
On 2/13/07, Patrick Spence <patrick@pkspence.com> wrote:
>
> I don't know if that has anything to do with the problems I'm still
> having. The #wait_until technique isn't working either. The decision of
> the development folks to convert the app to Ajax was made w/o consulting
> the QA department as to the possible ramifications. That, on top of the
> other problem has forced us to look at other alternatives to Ruby/Watir.
> It's a bloody shame too as we've made a sizable investment in the
> development of the core code and classes in Ruby.


Don't give up too soon. We have plenty of Watir users who are using
Watir
1.5 to test Ajax applications.

Bret
24c6e4ed08f7a4bf9cfb7edc2dbd14b8?d=identicon&s=25 Patrick Spence (pkspence)
on 2007-02-14 00:26
Bret Pettichord wrote:
> Don't give up too soon. We have plenty of Watir users who are using
> Watir
> 1.5 to test Ajax applications.
>
> Bret

Any further input or advice would be greatly appreciated! I love the
Ruby/Watir combination. BTW, I don't what you've done with the latest
build of Watir; v1.5.1, but it's so fast it's almost frightening! Up
until a couple of days ago I was using v1.4 and running a script w/in
the Komodo IDE was painfully slow. With the latest build, even while
running w/in Komodo, the scripts run as fast as the previous build did
as a standalone script. Outstanding work!
F5e913e74387bb2e1d00826994802021?d=identicon&s=25 alex_f_il@hotmail.com (Guest)
on 2007-03-16 16:55
(Received via mailing list)
On Feb 11, 5:56 pm, "Bret Pettichord" <bpettich...@gmail.com> wrote:
> On Feb 5, 11:53 am, "alex_f...@hotmail.com" <alex_f...@hotmail.com>
> wrote:
>
> > I don't think it is possible with currentWATIRimplementation.
>
> Why do you say this?

The IE automation is very complex problem. The Browser is "alive". You
can't lock the browser. You can test for the tag existence and it will
fail on the next line because DOM was changed.   SWExplorerAutomation
(SWEA) automates Browser from "inside". The SWEA engine sits inside IE
and controls all browser activity.  WATIR works from outside of IE.
All WATIR calls to IE are marshaled (DCOM). It slows down the
automation performance and makes the automation less reliable.
68db3bafb0a990bf605c4cf62bf85db0?d=identicon&s=25 Bret Pettichord (Guest)
on 2007-03-20 17:30
(Received via mailing list)
On Mar 16, 10:50 am, "alex_f...@hotmail.com" <alex_f...@hotmail.com>
wrote:

> The IE automation is very complex problem. The Browser is "alive". You
> can't lock the browser. You can test for the tag existence and it will
> fail on the next line because DOM was changed.   SWExplorerAutomation
> (SWEA) automates Browser from "inside". The SWEA engine sits inside IE
> and controls all browser activity.

So SWEA is able to lock the browser? How would you know when to do
this? Is this a good thing? Is this a feature that should be added to
Watir? I don't understand how a user would use this ability, so i
would appreciate any clarification. Can you show me some code that
does this?

Bret
F5e913e74387bb2e1d00826994802021?d=identicon&s=25 alex_f_il@hotmail.com (Guest)
on 2007-03-20 21:40
(Received via mailing list)
On Mar 20, 12:28 pm, "Bret Pettichord" <bpettich...@gmail.com> wrote:
> this? Is this a good thing? Is this a feature that should be added toWatir? I don't 
understand how a user would use this ability, so i
> would appreciate any clarification. Can you show me some code that
> does this?
>
> Bret

SWEA doesn't block the browser - it could be a very bad idea to block
the browser. SWEA monitors all Browser activity in real-time and is
able correctly rebind (reidentify) SWEA controls in the case of the
changes. It makes automation script more reliable and stable. Try to
automate any complex AJAX grid using WATIR (run test 100 times) and
you will see the problem. You will need to place "sleep" statements to
make the script work stable.
151b20c72716eb93ac58fa16fb94ec23?d=identicon&s=25 Bret Pettichord (Guest)
on 2007-03-20 22:38
(Received via mailing list)
On 3/20/07, alex_f_il@hotmail.com <alex_f_il@hotmail.com> wrote:
>
> SWEA doesn't block the browser - it could be a very bad idea to block
> the browser. SWEA monitors all Browser activity in real-time and is
> able correctly rebind (reidentify) SWEA controls in the case of the
> changes. It makes automation script more reliable and stable. Try to
> automate any complex AJAX grid using WATIR (run test 100 times) and
> you will see the problem. You will need to place "sleep" statements to
> make the script work stable.


Watir scripts don't need to rebind then there are changes. Watir objects
reference elements of the DOM and these references are stable until the
element no longer exists or a new page is loaded.

I have run many complex scripts multiple times in Watir without problem.
What kinds of problems are you seeing? Are the scripts slowing down? Are
you
getting intermittent failures? Memory leaks? It sounds scary when you
say it
is not stable or reliable, but I'm not getting a clear picture of what
this
looks like to you.

As mentioned earlier in the thread, people using Watir to test Ajax
typically use the "wait_until" method to avoid sleep statements. I would
like to see an example where this wasn't an option. I agree: sleeps
should
be avoided.

Bret
68db3bafb0a990bf605c4cf62bf85db0?d=identicon&s=25 Bret Pettichord (Guest)
on 2007-03-23 16:21
(Received via mailing list)
On 3/20/07, alex_f_il@hotmail.com <alex_f_il@hotmail.com> wrote:

    SWEA doesn't block the browser - it could be a very bad idea to
block
    the browser. SWEA monitors all Browser activity in real-time and
is
    able correctly rebind (reidentify) SWEA controls in the case of
the
    changes. It makes automation script more reliable and stable. Try
to
    automate any complex AJAX grid using WATIR (run test 100 times)
and
    you will see the problem. You will need to place "sleep"
statements to
    make the script work stable.


Watir scripts don't need to rebind then there are changes. Watir
objects reference elements of the DOM and these references are stable
until the element no longer exists or a new page is loaded.

I have run many complex scripts multiple times in Watir without
problem. What kinds of problems are you seeing? Are the scripts
slowing down? Are you getting intermittent failures? Memory leaks? It
sounds scary when you say it is not stable or reliable, but I'm not
getting a clear picture of what this looks like to you.

As mentioned earlier in the thread, people using Watir to test Ajax
typically use the "wait_until" method to avoid sleep statements. I
would like to see an example where this wasn't an option. I agree:
sleeps should be avoided.

Bret
F5e913e74387bb2e1d00826994802021?d=identicon&s=25 alex_f_il@hotmail.com (Guest)
on 2007-03-24 05:56
(Received via mailing list)
On Mar 23, 11:19 am, "Bret Pettichord" <bpettich...@gmail.com> wrote:
>     automate any complex AJAX grid usingWATIR(run test 100 times)
> problem. What kinds of problems are you seeing? Are the scripts
> slowing down? Are you getting intermittent failures? Memory leaks? It
> sounds scary when you say it is not stable or reliable, but I'm not
> getting a clear picture of what this looks like to you.
>
> As mentioned earlier in the thread, people usingWatirto test Ajax
> typically use the "wait_until" method to avoid sleep statements. I
> would like to see an example where this wasn't an option. I agree:
> sleeps should be avoided.
>
> Bret

I don't want to say you can't use WATIR with AJAX, but it can take a
lot of efforts to write the scripts and make them work stable.
Unfortunately, the tests are not we paid for after all.
BTW, is there any WATIR recorder which can record the AJAX scripts?
F5e913e74387bb2e1d00826994802021?d=identicon&s=25 alex_f_il@hotmail.com (Guest)
on 2007-03-24 15:01
(Received via mailing list)
On Mar 23, 11:19 am, "Bret Pettichord" <bpettich...@gmail.com> wrote:
>     automate any complex AJAX grid usingWATIR(run test 100 times)
> problem. What kinds of problems are you seeing? Are the scripts
> slowing down? Are you getting intermittent failures? Memory leaks? It
> sounds scary when you say it is not stable or reliable, but I'm not
> getting a clear picture of what this looks like to you.
>
> As mentioned earlier in the thread, people usingWatirto test Ajax
> typically use the "wait_until" method to avoid sleep statements. I
> would like to see an example where this wasn't an option. I agree:
> sleeps should be avoided.
>
> Bret

Small correction: Watir keeps references to the element proxies. The
DOM elements are located in the IE process. Every check for the
element availability is marshalled between the processes (test script
and IE).

-Alex
This topic is locked and can not be replied to.