Selenium-IDE is the Integrated Development Environment for building Selenium test cases. It operates as a Firefox add-on and provides an easy-to-use interface for developing and running individual test cases or entire test suites. Selenium-IDE has a recording feature, which will keep account of user actions as they are performed and store them as a reusable script to play back. It also has a context menu (right-click) integrated with the Firefox browser, which allows the user to pick from a list of assertions and verifications for the selected location. Selenium-IDE also offers full editing of test cases for more precision and control. Although Selenium-IDE is a Firefox only add-on, tests created in it can also be run against other browsers by using Selenium-RC and specifying the name of the test suite on the command line.
Features:
Easy record and playback
Intelligent field selection will use IDs, names, or XPath as needed
Auto complete for all common Selenium commands
Walk through tests
Debug and set breakpoints
Save tests as HTML, Ruby scripts, or any other format
Support for Selenium user-extensions.js file
Option to automatically assert the title of every page
Selenium-RC:
Selenium-RC allows the test automation developer to use a programming language for maximum flexibility and extensibility in developing test logic. For instance, if the application under test returns a result set, and if the automated test program needs to run tests on each element in the result set, the programming language’s iteration support can be used to iterate through the result set, calling Selenium commands to run tests on each item.
Selenium-RC provides an API (Application Programming Interface) and library for each of its supported languages: HTML, Java, C#, Perl, PHP, Python, and Ruby. This ability to use Selenium-RC with a high-level programming language to develop test cases also allows the automated testing to be integrated with a project’s automated build environment.
Selenium TestNG with Eclipse Configuration
In order to configure selenium TestNG with Eclipse we need to follow the below steps, I have also mentioned about configuring selenium server in eclipse with the help of which we will be able to see selenium server in console bar within eclipse, the steps are as follows.
Start Eclipse:
Goto path where eclipse application is stored.
Launch eclipse by double clicking the Eclipse icon.
Browse the workspace directory where you want to store all your project contents.
Eclipse is launched now.
Creating New Project:
Goto to File menu select new than click on new project.
From displayed list select JAVA project and click next.
Give the appropriate project name than click next.
Now to add external libraries click on libraries than click add external Jars..
Browse the external Jars and add it.
Click on finish button.
External JARs:
TestNG 5.14.1:
TestNG is a testing framework designed to simply a broad range of testing needs, from unit testing(testing a class in isolation of the others),functional testing,browser-compatibility testing with Selenium-RC to integration testing (testing entire systems made of several classes, several packages and even several external frameworks, such as application servers).
Learn more about TestNG here:http://testng.org/doc/documentation-main.html
Now lets start implementing it.
First you need to record a script in selenium-ide,just try with a simple script and put some check points(to know how Selenium ide works visit:http://seleniumhq.org/projects/ide/)
Now convert your IDE script to any language as selenium supports multiple platforms like junit,TestNG,Python,C#.
Here i have used TestNG because of it's powerfull features like multi threading and annotaions
so convert the IDE script into TestNG format like this:
selenium-java-client-driver:
Add the selenium-java-client-driver.jar files to your project as references.
Add to your project classpath the file selenium-java-client-driver.jar.
To download refernece libraries follow the link below.
http://seleniumhq.org/download/
Configuring selenium server:
We can configure Selenium server by clicking on Run and click on 'External Tools' and click on 'External Tool Configurations' then you will get a window opened
Now browse the java .exe file and paste the path in the Location Text box
Location: C:\Program Files\Java\jdk1.5.0_06\bin\java.exe
Now browse the Selenium Server file folder and paste the path location in Working Directory Text box
Working Directory: C:\Program Files\Selenium\selenium-remote-control-1.0.1\selenium-server-1.0.1
Pass Arguments as -jar selenium-server.jar
Now click on Apply button and click on Run and you can see server running on the port 4444
Now we have to instantiate selenium server in order to run your script,so we need to create the selenium instances in our scripts. Given below is the code about how we instantiate selenium server on a particular host to launch the scripts
public class TestScript {
private Selenium selenium;
@BeforeClass
@Parameters({"selenium.host","selenium.port","selenium.browser","selenium.url"})
public void startSelenium(String host,String port,String browser,String url) {
this.selenium = new DefaultSelenium(host, Integer.parseInt(port), browser, url);
this.selenium.start();
this.selenium.open(url);
}
Add this before your code,now we have to pass values to the parameters as you can see in the above code to launch selenium server.we define parameters values in xml.here youc an see how the xml structure looks like:
Run As
Now run the Eclipse using Run as and click on Apply and Run
once your script is successfully completed then you can see the reports in your workspace directory in test-output folder.