In this post, we will learn to install and configure Selenium 2 in our system step by step. We will use Java to write our test scripts for selenium, so we configure our Selenium set up using JAVA and Eclipse. We need following components to configure Selenium:
1. Java Development Kit: It is a tool kit that contains jar files responsible for writing and running of Java program.
2. Eclipse IDE: It is a Java-based open source platform that allows a software developer to create a customized development environment (IDE) from plugin components.
3. Selenium Java Client Driver: Selenium webdriver supports many languages and each language has its own client driver. Here we are configuring Selenium 2 with java so we need 'Selenium Java client driver'.
4. Selenium Server: It is basically a selenium RC server and is required when you write your test scripts using Selenium RC API or when you want to connect to a remote machine. If your browser and tests will all run on the same machine, and your tests only use the WebDriver API, then you do not need to run the Selenium-Server.
We will now learn how to download and install Java Development Kit (JDK) and Eclipse in your system and how to download and configure Java client driver and Selenium server inside Eclipse.
As you click the JDK link, a dialog box will appear asking to save the file. Save the file on your system and double click it to install JDK.
This JDK version comes bundled with Java Runtime Environment (JRE) so you do not need to download and install the JRE separately.
Extract the zip file and save it anywhere on your system. Inside the ZIP file, there is an “eclipse” folder which contains all the application files and the "eclipse.exe" file. You can run 'eclipse.exe' directly so no installation is required to use Eclipse. Create a shortcut on Desktop for "eclipse.exe" for your convenience.
1. Java Development Kit: It is a tool kit that contains jar files responsible for writing and running of Java program.
2. Eclipse IDE: It is a Java-based open source platform that allows a software developer to create a customized development environment (IDE) from plugin components.
3. Selenium Java Client Driver: Selenium webdriver supports many languages and each language has its own client driver. Here we are configuring Selenium 2 with java so we need 'Selenium Java client driver'.
4. Selenium Server: It is basically a selenium RC server and is required when you write your test scripts using Selenium RC API or when you want to connect to a remote machine. If your browser and tests will all run on the same machine, and your tests only use the WebDriver API, then you do not need to run the Selenium-Server.
We will now learn how to download and install Java Development Kit (JDK) and Eclipse in your system and how to download and configure Java client driver and Selenium server inside Eclipse.
Step 1: Download and Install JDK
1. Click here to download Java Development Kit. Click the radio button as shown in below image and click on the JDK link as per your Operating System. For now, I have clicked JDK link for Windows 7.As you click the JDK link, a dialog box will appear asking to save the file. Save the file on your system and double click it to install JDK.
This JDK version comes bundled with Java Runtime Environment (JRE) so you do not need to download and install the JRE separately.
2. Configure JDK path in the System as follow
a). Go to My Computer-> Properties. Select Advanced System Settings. A dialog box will be opened. Click Environment Variables. A new dialog will appear.
b). Click New button in User Variables. Enter Variable Name: Java_Home and Variable value: "C:\Program Files\Java\jdk1.7.0_11" in the dialog box displayed. (You need to enter the path where your jdk is stored). Click OK button.
c). Select Variable: Path from the list in System Variables and Click Edit button. Add "C:\Program Files\Java\jdk1.7.0_11\bin;" to the Variable value in the dialog box displayed. (You need to enter the path of your jdk bin). Click OK button.
d). Click OK button on the System Properties window. JDK is successfully configured in the system.
Step 2: Download Eclipse IDE
Download Eclipse IDE for Java EE Developers. Make sure you select correctly between Windows 32 bit and Windows 64 bit versions. Choose the Eclipse version you want to work on. Eclipse Indigo is recommended to be used as the latest version "Juno" might have some unresolved issues.You should be able to download a ZIP file named “eclipse-jee-indigo-SR2-win32-x86_64.zip”.Step 3: Download Selenium Server
Click here to go on the download page for Selenium Server. Click on the link as mentioned in below image to download Selenium Server. (Selenium version is changing time to time so it may be a different version when you will visit download page)
Save it own your system as per your choice.
Step 4: Download Selenium Java Client Driver
Click here to go on the page from where we download Selenium Java Client Driver. You will find client drivers for other languages there, but only choose the one for Java as shown in image. Click the link marked in red color to download Selenium 2 Java Client driver.
(Selenium version is changing time to time so it may be a different version when you will visit download page)
Downloaded file will be in zip format named as "selenium-java-2.35.0.zip". Extract the zip file and save it own your system as per your choice. This directory contains all the jar files which will be used to configure inside Eclipse.
Step 5: Create a New Project in Eclipse
1. Launch Eclipse IDE by double clicking the "eclipse.exe-Shortcut" icon that we made on desktop in Step 2
2. At the first time on starting Eclipse, it will ask to select your workspace where your work will be stored. Just accept the default location and click OK button. (You can also give the workspace location as per your choice).
3. Eclipse will get opened. Click Workbench icon on Welcome screen.
4. Create a new Project from File->New->Project. A dialog box will be opened.
5. Select Java Project and click Next Button.
6. Give any Project Name as per your choice, eg: SeleniumProject and click 2nd radio button as shown in image and then click Finish button.
7. A dialog box will appear asking to open a Perspective view. This is not needed right now so select "No" button.
8. Your Project will be created and appear like as shown in the image.
9. Create a Package: Right click on the newly created project and select New->Package and name the package as per your choice. eg: seleniumpkg. Click Finish button.
10. Create a Class: Right click on the newly created package and select New->Class and name your class as per your choice. eg: TestClass. Click Finish button.
11. Now your Eclipse window will look like below.
Step 6: Add Selenium 2 external jar files to the new project:
a). Right click the "SeleniumProject" and select Build Path-> Configure Build Path. A dialog box will be opened.
b). Select Libraries->Click Add External Jars-> Select both .jar files in selenium-2.35.0 folder and Selenium Server jar file named "selenium-server-standalone-2.35.0.jar" -> Click Open.
c). The dialog box will appear as shown below. Click OK button.
Finally, we have successfully configured Selenium libraries into our project. Now you are ready to write your test scripts in eclipse and run it in WebDriver or through Selenium RC server.
Great Post....
ReplyDeleteVery Easy for a beginner to understand