Selenium is a portable software testing framework for web applications. Selenium provides a record tool for authoring tests without learning a test scripting language (Selenium IDE). It also provides a test domain specific language(Selenese) to write tests in number of programming languages, including JAVA, C#, Perl, PHP, Python and Ruby. The tests can be run in modern browsers.
2. SELENIUM COMPONENTS
2.1 Selenium IDE
It is the complete IDE for Selenium testing. It is implemented as Firefox extension and allows recording, editing and debugging tests. Scripts may be automatically recorded and edited manually providing auto completion support and the ability to move commands around quickly. Scripts are recorded in Selenese, a special test scripting language for Selenium. Selenese provides commands for performing actions in a browser (click a link, select an option), and for retrieving data from the resulting pages. Selenium IDE is a plug-in for Firefox that record tests. We can then export the recorded tests as conditions, iterations, and so on.
Open Selenium IDE by clicking Tools > Selenium IDE in Firefox.
Selenium IDE of firefox is
2.2 Selenium Client API
As an alternative to writing tests in Selenese, tests can also be written in various programming languages. These tests then communicate with Selenium by calling methods in the Selenium Client API. Selenium currently provides client APIs for Java, C#, Ruby and Python. With Selenium 2, a new Client API was introduced (with WebDriver as its central component). However, the old API is still supported.
2.3 Selenium Remote Control (RC)
Selenium Remote Control (RC) is a server, written in Java, which accepts commands for the browser via HTTP. RC makes it possible to write automated tests for a web application in any programming language, which allows for better integration of Selenium in existing unit test frameworks. Selenium project currently provides client drivers for PHP, Python, Ruby, Perl and JAVA. A new instance of selenium RC server is needed to launch HTML test case. However for Java/PHP test case only one Selenium RC instance needs to be running continuously. With the release of Selenium 2, Selenium RC has been officially deprecated in favor of Selenium WebDriver.
The Selenium server is simply a JAR file that you can run using the Java Runtime Environment (JRE). You can execute the Selenium server by running the following command in command prompt:
java -jar selenium-server.jar
Before performing actions in Selenium IDE, start the server and begin using the web application.
2.4 Selenium WebDriver
Selenium WebDriver is the successor to Selenium RC. Selenium WebDriver accepts commands (sent in Selenese, or via a Client API) and sends them to a browser. This is implemented through a browser-specific browser driver, which sends commands to a browser, and retrieves results.
Selenium-Web Driver was developed to better support dynamic web pages where elements of a page may change without the page itself being reloaded. WebDriver goal is to supply a well-designed object-oriented API that provides improved support for modern advanced web-app testing problems.
3. SELENIUM INTEGRATION WITH TESTLINK
Integration is nothing more than sending the execution result of the test script for Testlink. We will create a Java project with the support of JUnit for creating the test script with Selenium.
- TestLink Version 1.9
- Testlink-api-client-2.0 and XMLRPC Client libraries.
- Java IDE(Eclipse)
- Selenium RC Libraries.
Exporting JUnit webdriver backed from selenium IDE.
3.2 Configure TestLink
◦ Create new project in testlink and enable the project with automation testing.
◦ Generate new access key. After you enable the API access to XML-RPC and report the activation of automation in the configuration file is necessary to generate the key. This key is created by user and that it will allow the Testlink identify who is trying to access the XML-RPC services.
3.3 Preparing Development Environment
Add all jar into libs in eclipse.
- Selenium RC: selenium-server.jar
- Junit libs.
3.4 Sample Code
- Create a JUnit class named “Selenium_Methods ” and copy the following code:-
- Create a class TestClass ,which is responsible for sending the result of the script to Testlink.
- Create an interface Iconstants, with the data necessary to send the data to the Testlink, which are the parameters that were described above.
On this interface we gave all details of project in TestLink such as devkey, URL, ProjectName, TestPlanName, BuildName and TestcaseName.
After creating all the needed, run as JUnit test. After execution, the Result will be automatically reflected to TestLink as below.