# Ajax woes

**URL:** <https://rubytalk.org/t/ajax-woes/35086>\
**Category:** ruby-talk\
**Created:** [5 February 2007 14:56 UTC](https://rubytalk.org/t/ajax-woes/35086 "2007-02-05T14:56:34Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Patrick\_Spence2](https://avatars.discourse-cdn.com/v4/letter/p/e9bcb4/32.png) [@Patrick\_Spence2](https://rubytalk.org/u/Patrick_Spence2)\
**Post date:** [5 February 2007 14:56 UTC](https://rubytalk.org/t/ajax-woes/35086/1 "2007-02-05T14:56:34Z")

</div>

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:

&nbsp;&nbsp;def test\_0001\_username()  
&nbsp;&nbsp;&nbsp;&nbsp;sleep(2)  
&nbsp;&nbsp;&nbsp;&nbsp;@@ie.text\_field(:id,'ctl00\_lgnLogin\_UserName').set('TEST-5038')  
&nbsp;&nbsp;end

&nbsp;&nbsp;def test\_0002\_password()  
&nbsp;&nbsp;&nbsp;&nbsp;sleep(2)  
&nbsp;&nbsp;&nbsp;&nbsp;@@ie.text\_field(:id,'ctl00\_lgnLogin\_Password').set('passw0rd')  
&nbsp;&nbsp;end

&nbsp;&nbsp;def test\_0003\_loginButton()  
&nbsp;&nbsp;&nbsp;&nbsp;sleep(2)  
&nbsp;&nbsp;&nbsp;&nbsp;@@ie.button(:id,'ctl00\_lgnLogin\_LoginButton').click  
&nbsp;&nbsp;end

Has anyone else run into this and what was your solution? Thanks!

> **···**
>
> --  
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).

---

<div class="post-metadata">

**Author:** ![Jason\_R](https://avatars.discourse-cdn.com/v4/letter/j/94ad74/32.png) [@Jason\_R](https://rubytalk.org/u/Jason_R)\
**Post date:** [5 February 2007 15:04 UTC](https://rubytalk.org/t/ajax-woes/35086/2 "2007-02-05T15:04:08Z")

</div>

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

> **···**
>
> On 2/5/07, Patrick Spence \<patrick@pkspence.com\> wrote:
> 
> > 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:
> > 
> > &nbsp;&nbsp;def test\_0001\_username()  
> > &nbsp;&nbsp;&nbsp;&nbsp;sleep(2)  
> > &nbsp;&nbsp;&nbsp;&nbsp;@@ie.text\_field(:id,'ctl00\_lgnLogin\_UserName').set('TEST-5038')  
> > &nbsp;&nbsp;end
> > 
> > &nbsp;&nbsp;def test\_0002\_password()  
> > &nbsp;&nbsp;&nbsp;&nbsp;sleep(2)  
> > &nbsp;&nbsp;&nbsp;&nbsp;@@ie.text\_field(:id,'ctl00\_lgnLogin\_Password').set('passw0rd')  
> > &nbsp;&nbsp;end
> > 
> > &nbsp;&nbsp;def test\_0003\_loginButton()  
> > &nbsp;&nbsp;&nbsp;&nbsp;sleep(2)  
> > &nbsp;&nbsp;&nbsp;&nbsp;@@ie.button(:id,'ctl00\_lgnLogin\_LoginButton').click  
> > &nbsp;&nbsp;end
> > 
> > Has anyone else run into this and what was your solution? Thanks!
> > 
> > --  
> > Posted via [http://www.ruby-forum.com/\](http://www.ruby-forum.com/%5C).

---

<div class="post-metadata">

**Author:** ![Bret\_Pettichord](https://avatars.discourse-cdn.com/v4/letter/b/9fc348/32.png) [@Bret\_Pettichord](https://rubytalk.org/u/Bret_Pettichord)\
**Post date:** [11 February 2007 22:00 UTC](https://rubytalk.org/t/ajax-woes/35086/3 "2007-02-11T22:00:08Z")

</div>

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

&nbsp;&nbsp;&nbsp;def test\_0001\_username()  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Watir::wait\_until {@@ie.text\_field(:id,  
'ct100\_lgnLogin\_UserName').exists?}  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;@@ie.text\_field(:id,'ctl00\_lgnLogin\_UserName').set('TEST-5038')  
&nbsp;&nbsp;&nbsp;end

Bret

> **···**
>
> On Feb 5, 8:56 am, Patrick Spence \<patr...@pkspence.com\> wrote:
> 
> > &nbsp;&nbsp;def test\_0001\_username()  
> > &nbsp;&nbsp;&nbsp;&nbsp;sleep(2)  
> > &nbsp;&nbsp;&nbsp;&nbsp;@@ie.text\_field(:id,'ctl00\_lgnLogin\_UserName').set('TEST-5038')  
> > &nbsp;&nbsp;end

---

<div class="post-metadata">

**Author:** ![Patrick\_Spence2](https://avatars.discourse-cdn.com/v4/letter/p/e9bcb4/32.png) [@Patrick\_Spence2](https://rubytalk.org/u/Patrick_Spence2)\
**Post date:** [5 February 2007 17:21 UTC](https://rubytalk.org/t/ajax-woes/35086/4 "2007-02-05T17:21:14Z")

</div>

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.

> **···**
>
> --  
> Posted via [http://www.ruby-forum.com/\](http://www.ruby-forum.com/%5C).

---

<div class="post-metadata">

**Author:** ![Patrick\_Spence2](https://avatars.discourse-cdn.com/v4/letter/p/e9bcb4/32.png) [@Patrick\_Spence2](https://rubytalk.org/u/Patrick_Spence2)\
**Post date:** [12 February 2007 12:49 UTC](https://rubytalk.org/t/ajax-woes/35086/5 "2007-02-12T12:49:34Z")

</div>

Bret Pettichord wrote:

> **···**
>
> > On Feb 5, 8:56 am, Patrick Spence \<patr...@pkspence.com\> wrote:
> > 
> > > &nbsp;&nbsp;def test\_0001\_username()  
> > > &nbsp;&nbsp;&nbsp;&nbsp;sleep(2)  
> > > &nbsp;&nbsp;&nbsp;&nbsp;@@ie.text\_field(:id,'ctl00\_lgnLogin\_UserName').set('TEST-5038')  
> > > &nbsp;&nbsp;end
> > 
> > Actually, the latest version (1.5) of Watir \*does\* support Ajax. Thus:
> > 
> > &nbsp;&nbsp;&nbsp;def test\_0001\_username()  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Watir::wait\_until {@@ie.text\_field(:id,  
> > 'ct100\_lgnLogin\_UserName').exists?}  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;@@ie.text\_field(:id,'ctl00\_lgnLogin\_UserName').set('TEST-5038')  
> > &nbsp;&nbsp;&nbsp;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.
> 
> --  
> Posted via [http://www.ruby-forum.com/\](http://www.ruby-forum.com/%5C).

---

<div class="post-metadata">

**Author:** ![alex\_f\_il](https://avatars.discourse-cdn.com/v4/letter/a/2bfe46/32.png) [@alex\_f\_il](https://rubytalk.org/u/alex_f_il)\
**Post date:** [5 February 2007 17:55 UTC](https://rubytalk.org/t/ajax-woes/35086/6 "2007-02-05T17:55:11Z")

</div>

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.

> **···**
>
> On Feb 5, 12:21 pm, Patrick Spence \<patr...@pkspence.com\> wrote:
> 
> > Jason Roelofs wrote:  
> > \> There is a method on @@ie (i'm assumingWatirusage 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.
> > 
> > --  
> > Posted viahttp://www.ruby-forum.com/.

---

<div class="post-metadata">

**Author:** ![Patrick\_Spence2](https://avatars.discourse-cdn.com/v4/letter/p/e9bcb4/32.png) [@Patrick\_Spence2](https://rubytalk.org/u/Patrick_Spence2)\
**Post date:** [12 February 2007 13:10 UTC](https://rubytalk.org/t/ajax-woes/35086/7 "2007-02-12T13:10:29Z")

</div>

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!

> **···**
>
> --  
> Posted via [http://www.ruby-forum.com/\](http://www.ruby-forum.com/%5C).

---

<div class="post-metadata">

**Author:** ![Patrick\_Spence2](https://avatars.discourse-cdn.com/v4/letter/p/e9bcb4/32.png) [@Patrick\_Spence2](https://rubytalk.org/u/Patrick_Spence2)\
**Post date:** [9 February 2007 14:02 UTC](https://rubytalk.org/t/ajax-woes/35086/8 "2007-02-09T14:02:34Z")

</div>

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!

> **···**
>
> --  
> Posted via [http://www.ruby-forum.com/\](http://www.ruby-forum.com/%5C).

---

<div class="post-metadata">

**Author:** ![Bret\_Pettichord](https://avatars.discourse-cdn.com/v4/letter/b/9fc348/32.png) [@Bret\_Pettichord](https://rubytalk.org/u/Bret_Pettichord)\
**Post date:** [11 February 2007 22:00 UTC](https://rubytalk.org/t/ajax-woes/35086/9 "2007-02-11T22:00:09Z")

</div>

Why do you say this?

> **···**
>
> On Feb 5, 11:53 am, "alex\_f...@hotmail.com" \<alex\_f...@hotmail.com\> wrote:
> 
> > I don't think it is possible with currentWATIRimplementation.

---

<div class="post-metadata">

**Author:** ![Patrick\_Spence2](https://avatars.discourse-cdn.com/v4/letter/p/e9bcb4/32.png) [@Patrick\_Spence2](https://rubytalk.org/u/Patrick_Spence2)\
**Post date:** [12 February 2007 13:18 UTC](https://rubytalk.org/t/ajax-woes/35086/10 "2007-02-12T13:18:33Z")

</div>

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/](http://www.io.com/~wazmo/blog/), along with suggestion  
that those running v1.5 should update to 1.5.1.

> **···**
>
> --  
> Posted via [http://www.ruby-forum.com/\](http://www.ruby-forum.com/%5C).

---

<div class="post-metadata">

**Author:** ![Bret\_Pettichord1](https://avatars.discourse-cdn.com/v4/letter/b/258eb7/32.png) [@Bret\_Pettichord1](https://rubytalk.org/u/Bret_Pettichord1)\
**Post date:** [13 February 2007 00:37 UTC](https://rubytalk.org/t/ajax-woes/35086/11 "2007-02-13T00:37:09Z")

</div>

[http://wiki.openqa.org/display/WTR/Development+Builds](http://wiki.openqa.org/display/WTR/Development+Builds)

But there seems to be a problem with the gem attachments at the moment...

> **···**
>
> 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?

---

<div class="post-metadata">

**Author:** ![Patrick\_Spence2](https://avatars.discourse-cdn.com/v4/letter/p/e9bcb4/32.png) [@Patrick\_Spence2](https://rubytalk.org/u/Patrick_Spence2)\
**Post date:** [13 February 2007 19:02 UTC](https://rubytalk.org/t/ajax-woes/35086/12 "2007-02-13T19:02:42Z")

</div>

Bret Pettichord 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](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.

> **···**
>
> > On 2/12/07, Patrick Spence \<patrick@pkspence.com\> wrote:
> 
> --  
> Posted via [http://www.ruby-forum.com/\](http://www.ruby-forum.com/%5C).

---

<div class="post-metadata">

**Author:** ![alex\_f\_il](https://avatars.discourse-cdn.com/v4/letter/a/2bfe46/32.png) [@alex\_f\_il](https://rubytalk.org/u/alex_f_il)\
**Post date:** [16 March 2007 15:55 UTC](https://rubytalk.org/t/ajax-woes/35086/13 "2007-03-16T15:55:05Z")

</div>

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.

> **···**
>
> 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?

---

<div class="post-metadata">

**Author:** ![Bret\_Pettichord1](https://avatars.discourse-cdn.com/v4/letter/b/258eb7/32.png) [@Bret\_Pettichord1](https://rubytalk.org/u/Bret_Pettichord1)\
**Post date:** [13 February 2007 20:32 UTC](https://rubytalk.org/t/ajax-woes/35086/14 "2007-02-13T20:32:43Z")

</div>

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

Bret

> **···**
>
> 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.

---

<div class="post-metadata">

**Author:** ![Bret\_Pettichord](https://avatars.discourse-cdn.com/v4/letter/b/9fc348/32.png) [@Bret\_Pettichord](https://rubytalk.org/u/Bret_Pettichord)\
**Post date:** [20 March 2007 16:30 UTC](https://rubytalk.org/t/ajax-woes/35086/15 "2007-03-20T16:30:07Z")

</div>

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

> **···**
>
> 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.

---

<div class="post-metadata">

**Author:** ![Patrick\_Spence2](https://avatars.discourse-cdn.com/v4/letter/p/e9bcb4/32.png) [@Patrick\_Spence2](https://rubytalk.org/u/Patrick_Spence2)\
**Post date:** [13 February 2007 23:26 UTC](https://rubytalk.org/t/ajax-woes/35086/16 "2007-02-13T23:26:31Z")

</div>

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!

> **···**
>
> --  
> Posted via [http://www.ruby-forum.com/\](http://www.ruby-forum.com/%5C).

---

<div class="post-metadata">

**Author:** ![alex\_f\_il](https://avatars.discourse-cdn.com/v4/letter/a/2bfe46/32.png) [@alex\_f\_il](https://rubytalk.org/u/alex_f_il)\
**Post date:** [20 March 2007 20:40 UTC](https://rubytalk.org/t/ajax-woes/35086/17 "2007-03-20T20:40:07Z")

</div>

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.

> **···**
>
> On Mar 20, 12:28 pm, "Bret Pettichord" \<bpettich...@gmail.com\> wrote:
> 
> > 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 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

---

<div class="post-metadata">

**Author:** ![Bret\_Pettichord1](https://avatars.discourse-cdn.com/v4/letter/b/258eb7/32.png) [@Bret\_Pettichord1](https://rubytalk.org/u/Bret_Pettichord1)\
**Post date:** [20 March 2007 21:37 UTC](https://rubytalk.org/t/ajax-woes/35086/18 "2007-03-20T21:37:28Z")

</div>

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

> **···**
>
> 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.

---

<div class="post-metadata">

**Author:** ![Bret\_Pettichord](https://avatars.discourse-cdn.com/v4/letter/b/9fc348/32.png) [@Bret\_Pettichord](https://rubytalk.org/u/Bret_Pettichord)\
**Post date:** [23 March 2007 15:20 UTC](https://rubytalk.org/t/ajax-woes/35086/19 "2007-03-23T15:20:07Z")

</div>

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

> **···**
>
> On 3/20/07, [alex\_f\_il@hotmail.com](mailto:alex_f_il@hotmail.com) \<[alex\_f\_il@hotmail.com](mailto:alex_f_il@hotmail.com)\> wrote:

---

<div class="post-metadata">

**Author:** ![alex\_f\_il](https://avatars.discourse-cdn.com/v4/letter/a/2bfe46/32.png) [@alex\_f\_il](https://rubytalk.org/u/alex_f_il)\
**Post date:** [24 March 2007 04:55 UTC](https://rubytalk.org/t/ajax-woes/35086/20 "2007-03-24T04:55:06Z")

</div>

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?

> **···**
>
> On Mar 23, 11:19 am, "Bret Pettichord" \<bpettich...@gmail.com\> wrote:
> 
> > On 3/20/07, alex\_f...@hotmail.com \<alex\_f...@hotmail.com\> wrote:
> > 
> > &nbsp;&nbsp;&nbsp;&nbsp;SWEA doesn't block the browser - it could be a very bad idea to  
> > block  
> > &nbsp;&nbsp;&nbsp;&nbsp;the browser. SWEA monitors all Browser activity in real-time and  
> > is  
> > &nbsp;&nbsp;&nbsp;&nbsp;able correctly rebind (reidentify) SWEA controls in the case of  
> > the  
> > &nbsp;&nbsp;&nbsp;&nbsp;changes. It makes automation script more reliable and stable. Try  
> > to  
> > &nbsp;&nbsp;&nbsp;&nbsp;automate any complex AJAX grid usingWATIR(run test 100 times)  
> > and  
> > &nbsp;&nbsp;&nbsp;&nbsp;you will see the problem. You will need to place "sleep"  
> > statements to  
> > &nbsp;&nbsp;&nbsp;&nbsp;make the script work stable.
> > 
> > Watirscripts 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 inWatirwithout  
> > 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

[Next page](https://rubytalk.org/t/ajax-woes/35086.md?page=2)
