Environment Setup for Selenium WebDriver with Java
Selenium WebDriver is not a GUI tool, with Java programming language you have to download JAR (Java archive resource) files. This tutorial is a step by step guide where we will learn to setup environment for Selenium WebDriver with Java. Steps include downloading and installing Java, downloading and installing Eclipse IDE, downloading Selenium Jar files and configuring them in Eclipse.
Step1: Download and install the latest version of JDK (Java development kit) with JRE (Java runtime environment) (32 bit or 64 bit ) depending upon your operating system(Mac, Windows or Linux) operating system.
a) Select JDK download from the below options (it includes JRE).
b) Accept the License Agreement and Select the JDK version depending upon your Operating System. Download the JDK.
c) Install JDK by clicking next multiple times.
Configuring Java Home path:
Step2: Create environment variable by name “JAVA_HOME” and set this variable value to JDK installation location.
Right Click “This PC”–> Properties –>Advanced system settings –> Environment variables –> System Variables –> Add a variable “JAVA_HOME” and update it with path of JDK installation directory.
Step 3: Update “path” environment variable to the bin folder of JDK location.
In path variable of the System variables –> add a value %JAVA_HOME%\bin.
Importing Selenium WebDriver Java Bindings:
Step 4: Download latest version of webDriver Java language bindings ( file 1 – selenium-server-2.xx.x.zip file and file 2 – Selenium-standalone-2.xx.x.jar).
a) To download file 1 go to Selenium Client & WebDriver Language Bindings section and choose Java option.
b) To download file 2 go to Selenium Standalone Server section.
Step 5: Extract the above zip file, copy the srcs and standalone file to libs folder (Create a libs folder in your workspace).
Note: To download some older version of Selenium follow this link
Configuring Eclipse IDE:
Step 6: Download latest version of Eclipse IDE for j2ee developers (32 or 64 bits depending upon your Operating System).
Creating Java Project in Eclipse:
Step 7: Follow below steps to create a Selenium Project in Eclipse IDE:
a) File –> New –> Java Project. This will create a new project.
b) Enter Project name.
c) Keeping other configurations as default, Click Finish.
d) Right click src –> New –> Package –> <name of package>. This will create a new package.
Configuring Selenium Jar files in Java Project:
e) Right click project name –> Build Path –> Configure Build Path –> Libraries –> Add External Jar –> navigate to the path where jar files are kept (libs folder) –> Select the jar file –> Click on Apply –> Click OK. This will import Selenium jar files.
Now, we are ready to start coding. In the next tutorial, we will cover our first call flow using Selenium WebDriver – Working with Firefox
For any questions, queries or comments. Feel free to write us at firstname.lastname@example.org or email@example.com 🙂