Selenium Testing with Prototype AJAX

If you are using Selenium to test your web application and you are having some AJAX in it, you may know that the waitForCondition assertion is your friend.

According to the Selenium documentation it:

Runs the specified JavaScript snippet repeatedly until it evaluates to “true”.

With this you can define your own condition which defines the end of an AJAX call.

Since I am using Prototypes AJAX mostly, I found this standard waitForCondition quite helpful:

waitForCondition selenium.browserbot.getCurrentWindow().Ajax.activeRequestCount==0 30000

It waits until all ongoing AJAX calls are done and then continues. While this might not be suitable for all places it is definitively better than using the pause command.

Advertisements
This entry was posted in Selenium and tagged , . Bookmark the permalink.

One Response to Selenium Testing with Prototype AJAX

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s