Selenium is an open source software testing framework released under the Apache 2.0 license. It was built in 2004 by Jason Huggins and other testers at Thoughtworks. The name 'Selenium' came from an email in which Huggins mocked a competitor named 'Mercury' , saying that one can cure mercury poisoning by taking selenium supplements.
Selenium is mainly used for functional and regression testing. It is built in Java and is highly useful in web applications.
- Selenium IDE
- Selenium RC
- Selenium WebDriver
Selenium IDE (Integrated Development Environment) is a Firefox extension which allows recording, editing and debugging of tests. Selenium IDE was originally created by Shinya Kasatani and donated to the Selenium project in 2006. You can record and play tests using Selenium IDE. It reduces manual effort and saves time as it can be reused while retesting.
Scripts are recorded in Selenese, a special test scripting language for Selenium. Selenese provides commands for performing actions in a browser and for retrieving data from the resulting pages.
- Easy to record and run.
- Can create and run test suites (multiple tests).
- Can apply breakpoints at any point.
- Can edit scripts manually.
- Can save test scripts as Java, C# or any other language.
- Can easily assert title of any page.
Selenium RC (Remote Control, also known as Selenium 1) offers a more flexible and more complex approach to create run browser tests. With Selenium RC it is possible to run tests inside every JavaScript compatible browser using a wide range of programming languages. Your tests issue commands which the client library sends to the server. The server then 'runs' your actions in the browser and reports the results.
Selenium RC allows you to write automated tests in any supported programming language. Tests written in this way allow you to use standard programming practices making them easy to maintain, robust and easy to collaborate as a team. Selenium RC is a server, written in Java. It 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. To make writing tests easier, Selenium project currently provides client drivers for PHP, Python, Ruby, .NET, PERL and Java. The Java driver can also be used with JavaScript. A new instance of Selenium RC server is needed to launch HTML test cases, which means that the port should be different for each parallel run. However, for Java/PHP test cases, only one Selenium RC instance needs to run continuously.
Selenium WebDriver (also known as Selenium 2) is a browser automation framework that accepts commands (in Selenese or any other language; Java in our case) and send them to a browser. It is implemented through a browser-specific driver which sends commands to a browser and retrieves results.
- Cleaner APIs in WebDriver.
- Ability to handle multiple windows and modal windows effectively.
- Ability to handle mouse hover movements.
- Ability to handle window scrolls.
- Does not require Selenium RC server to be running.
- Native automation faster and a little less prone to error and browser configuration than Selenium RC.
We use:
IDE: Eclipse Helios and JUnit
Programming language: Java for writing scripts in Selenium WebDriver
Key features:
- Supports all the modern browsers (Firefox, Chrome, IE, Safari, Opera etc).
- Supports all operating systems (Windows, Linux , Mac).
- Cleaner APIs than Selenium RC.
- Object oriented programming based, hence gives accurate results.
- Can be used for Flash testing and Ajax handling
Selenium scripting is useful for handling projects which are complex and are of longer durations. Selenium is a widely used automation framework now.
1. Download the latest version of WebDriver from https://code.google.com/p/selenium/downloads/list (Select the java binding file to download)
2. Download Eclipse from eclipse.org downloads/index-helios.php
3. Download latest version of Java.
4. Extract files from the files from .zip Selenium WebDriver
5. Open Eclipse, create a new Java project .
6. Create a package under new Java project and then go to Configure build path .
8. From configure build path, click on Add external jars.
7. Add the jar files from the Selenium WebDriver folder that you have extracted.