Site icon EcoGujju

Functional testing of web applications with selenium

Functional testing

Many tools for automated web testing are protocol drivers. These tools drive the tests through the HTTP protocol. This is in many cases suitable to test the server side of the application. For applications that heavily use JavaScript, developers cannot use this approach.

In modern AJAX applications, the web client loads the HTML page only once, and JavaScript handles all subsequent communication with the server. Additionally, these applications often need to support multiple browsers.

Because browsers still handle JavaScript and the DOM differently today, a protocol driver proves relatively useless for testing, so testers need an application driver.

Selenium is a test tool which drives the test of a web application in the web browser. Selenium supports various browsers (IE, Firefox, Safari and most other browsers) on various platforms. The open source initiative around Selenium was started in 2004 by Jason Huggins.

Selenium is the type of non functional tools you need in order to test the application in the browser in the way manual testers would. JavaScript and the DOM are covered by your Selenium tests.

Selenium Core

At its core, Selenium is a set of JavaScript code that executes tests contained in an HTML table. Those tests life within the browser. The browser sees a test page which contains and drives your application. This is a simple concept but it is very effective and portable (to all the platforms mentioned above) at the same time.

Selenium IDE

Writing web application tests by hand without tool support is exhausting and almost impossible at lager scale in most of the testing companies. The tooling support you need is Selenium IDE. Selenium IDE is a Firefox extension for recording tests. It records all user interaction while browsing your application and you just need to add your verification steps while doing so.

The complete list of available selenium commands is available at Selenium Core TestRunner reference page:

A test case has been recorded. To resolve timing issues with execution of the JavaScript I had to insert a waitForElementPresent condition.

Selenium Remote Control (RC)

The Selenium RC provides a proxy server in order to treat the web application in a way that the browser thinks that the Selenium Core JavaScript files have the same origin as the web application. As a result, the browser does not violate the ‘same origin policy.

Run the server part of Selenium RC with “java -jar selenium-server.jar”. This is often also called Selenium Server.

Now we can easily execute the test case:

It takes additional overhead (~25 sec) to prepare the profile and launch the browser.

Selenium Grid

Selenium Grid is a platform to support parallel execution of test cases. The grid consists of multiple machines each running its own Selenium Server. Through parallel execution the completion time of automated web application testing can be drastically reduced.

Installation

Selenium IDE is a Firefox plugin. Open Firefox and select “Tools|add-ons|Get Add-ons”. Search for Selenium IDE and select “Add to Firefox”.

Everything else you usually need is in Selenium RC. Get the latest snapshot from:

At time of writing the latest snapshot resolved some issues with Firefox 3 on Ubuntu and OS X. Unpack the “selenium-python-client-driver” somewhere on your PYTHONPATH. You also need the selenium-server.jar to run the server part of Selenium RC.

Exit mobile version