Tuesday, July 7, 2009

Configuring Perl client for Selenium RC

For those trying to use python as the programming language in Selenium RC, the documentation is in the below link:

http://seleniumhq.org/docs/05_selenium_rc.html

For Perl, use the below steps:

Asssuming Selenium RC is downloaded and selenium server is running as per the steps in the above link.

1) download perl and install it. Let's say it is now installed in C:Perl.
2) C:\Documents and Settings\Desktop\selenium-remote-control-1.0-bet
a-2-dist\selenium-remote-control-1.0-beta-2\selenium-perl-client-driver-1.0-beta
-2>perl Makefile.pl
3) C:\Documents and Settings\Desktop\selenium-remote-control-1.0-bet
a-2-dist\selenium-remote-control-1.0-beta-2\selenium-perl-client-driver-1.0-beta
-2>nmake
4) C:\Documents and Settings\Desktop\selenium-remote-control-1.0-bet
a-2-dist\selenium-remote-control-1.0-beta-2\selenium-perl-client-driver-1.0-beta
-2>nmake install

With this you are all set to export your cases as Perl and execute them.

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.