Tuesday, July 7, 2009

Handling AJAX in Selenium

What is AJAX?

Ajax, sometimes written as AJAX (shorthand for asynchronous JavaScript and XML), is a group of interrelated web development techniques used on the client-side to create interactive web applications or rich Internet applications.

How does it affect testing automation?

Ajax page usually loads for some time. The automation script needs to wait for this "some time" before it can validate something in that page. We can make the script wait for some time say 5 seconds, but what if on a slow site, it takes more than 5 seconds. Our automation will fail in such scenarios.

Solution in Selenium

Use "click and wait" instead of "click". This command will wait for the page to load and all the elements to appear before validating for the elements present.

No comments:

Post a Comment