Wednesday, July 07, 2010

Testing your webapp using Selenium and PHPUnit

For a long time we have been testing our websites manually. Finally, we have decided to put in some effort to automate part of this testing. After a little bit of research, we found that Selenium could test any website in any set of browser-operating system combinations. There are some other equivalent tools, however selenium seems to be the most robust.

Selenium has many sub-projects. Selenium IDE is the best place for novices to start. Selenium IDE is a Firefox plugin that lets you record events in Firefox and replay them. Events can be like entering text in an input box. You can record a bunch of events like entering username, entering password, clicking on submit, etc. and replay them. Selenium has client libraries in almost all prevailing languages. You could record set of events in Selenium IDE and export the scripts to any of the supported languages. Java, Python, PHP, Ruby are some of the supported languages.

Replaying a script in Selenium IDE will execute the script inside Firefox. If you wish the execute the script in other browsers, then you will have to use a tool called Selenium RC. The acronym RC stands for remote client. Selenium RC is a jar file which can invoke any browser of your choice and execute the commands that you pass to it.

I have several instances of Selenium RC running, one in Windows, one in Mac and one in Linux. When I execute the PHP test scripts, they connect to Selenium RC running in various machines over the network and execute the scripts on a specific browser. This way you could test your website on all major browser and operating systems.

1 comment:

AKON said...

This is such a great resource that you are providing and you give it away for free. I love seeing blog that understand the value of providing a quality resource for free. Textile Testing Equipment