Selenium automates a web browser (headed or headless like phantomJs). It is used to automate only a web application, not any desktop program or application (it’s beyond the scope of it). It is a free (open source)automated testing suite for web applications across web browsers.It has four components.
- Integrated Development Environment (IDE)
- Remote Control (RC)
- WebDriver
- Grid
In this blog we will focus majorly on selenium WebDriver. Selenium-WebDriver was developed to support dynamic web pages where elements of a page changes without the page itself being reloaded. It makes direct calls to the browser using each browser’s native support for automation. Selenium supports languages like java, perl, php, C#, Ruby, JavaScript and Python.
Setting Up a Selenium-WebDriver
Install selenium basically means to set a project in development so we can write program using selenium. So here we will create a project in Java and write a simple program using WebDriver. Before going further, lets look at the pre-requirements:
- JDK(1.7 or later)
The JDK can be installed to your system from here. Java 1.8 is highly recommended for selenium 3.x and later updates. - Eclipse
For installing Eclipse we can go through this page. - Selenium Java Client Driver
The Selenium Java Client Driver can be downloaded from here. Make sure to choose the driver for Java, here we can get drivers for other languages too.
Configure Eclipse with WebDriver
The following are the steps to add a java project and to set/configure selenium to the added project:
- Open Eclipse and create a new project through File > New > Java Project, give the project name as convenient(say ‘gettingStarted’.
- Create a package under the project by, Right-click on created project > Selecting New > Package. Give the package name as per your need (say ‘pagkage1’).
- Under the package (‘pagkage1’) we need to create a new class, right-click on package and then select- New > Class. Let’s say the name of class is ‘Myfirstclass’.
The project Structure should look like the second image below:
Now, Lets include the selenium WebDriver’s into the project(or java build path). Following are steps to set WebDriver to the project:
- Right-click on the created project (‘gettingStarted’) and select Properties.
- On the opened dialog box, click on “Java Build Path”.
- Now, go to the Libraries tab, and select “Add External JARs..”
- Navigate to the file which was download at the time of downloading “Selenium Java Client Driver”, and select all the jar files and, click OK.
And yes, we are finally done importing Selenium libraries into our project. Now we can go further and add some code in the classes to obtain our testing flow/requirements.
In the next blog we will see how to Locate elements in selenium WebDriver.
1 comments