View source | Discuss page | Page history | Printable version   
ADVERTISEMENT
Accounting eLearning Courses
Partnerships
SourceForge.net Logo
Openbravo ERP at SourceForge

SourceForge.net Logo
Openbravo POS at SourceForge

Open Solution Alliance Logo
Openbravo at Open Solutions Alliance

Automated Testing/Selenium

Selenium

Selenium is a portable software testing framework for web applications.

It has a suite of tools that are useful for testing automation. Single test scripts can be recorded and played back using Selenium IDE. More complex tests can be written on various programming languages and executed using Selenium Remote Control. In addition, tests executions can be distributed using Selenium Grid.


Selenium IDE

Selenium IDE is a Firefox extension that allows to record, edit, debug and play back tests [1].

It can be downloaded at their website. Once installed, open it from the menu Tools->Selenium IDE of your Firefox browser.

The red button is used to record the actions performed on the browser. While you press buttons, select options and enter text, those actions are recorded and are stored as a table that you can run with the green play button.

View larger
View larger


Scripts are written as a three column HTML table; and they can be extended using Javascript files. For example, the following source code performs a login on Openbravo ERP.

<tr>
	<td>open</td>
	<td>/openbravo/security/Login_FS.html</td>
	<td></td>
</tr>
<tr>
	<td>type</td>
	<td>user</td>
	<td>Openbravo</td>
</tr>
<tr>
	<td>type</td>
	<td>password</td>
	<td>openbravo</td>
</tr>
<tr>
	<td>clickAndWait</td>
	<td>buttonOK</td>
	<td></td>
</tr>

In addition, Selenium IDE can be used to translate from HTML to one of the languages supported by the Remote Control.

Selenium Remote Control

Selenium Remote Control (RC) allows to write tests in any programming language that can make HTTP requests; using any mainstream JavaScript-enabled browser.

It can be downloaded from their website . This file includes the server and client libraries for Java, C#, Perl, PHP, Python and Ruby.

With Openbravo ERP we use the Java client driver to automate our integration tests. Previous HTML example of the login process will look like this using Java:

selenium.open("openbravo/security/Login_FS.html");
selenium.type("user", "Openbravo");
selenium.type("password", "openbravo");
selenium.click("buttonOK");
selenium.waitForPageToLoad("30000");

In order to execute the test, we need to start selenium server first:

java -jar /path/to/selenium-server.jar -multiWindow

Note: -multiWindow option is required to run the test in a separate browser window. If this parameter is not used, selenium runs in a subframe; that doesn't work with Openbravo ERP

Then, we use Junit4 to run the tests. For example, to execute this simple login scenario we write on the command line something like this:

java -classpath .:/path/to/junit-4.5.jar:/path/to/selenium-java-client-driver.jar 
org.junit.runner.JUnitCore Login

Note: Even though Selenium tests can be run without a testing framework, we have found some advantages while using Junit

Retrieved from "http://wiki.openbravo.com/wiki/Automated_Testing/Selenium"

This page has been accessed 894 times. This page was last modified 18:34, 10 March 2009. Content is available under Creative Commons Attribution-ShareAlike 2.5 Spain License.


Category: Automated Testing ERP