Selenium Webdriver- Environment Setup

To be able to use WebDriver for scripting, there are some pre-requisites that need to be in place like the basic environment setup. Users have to ensure that they have the initial configuration done. Setting up the environment involves the following steps.

  • Download and Install Java
  • Download and Configure Eclipse
  • Configure Selenium WebDriver

Download and Install Java

Step 1: Navigate to the Oracle official site URL: http://www.oracle.com/technetwork/java/javase/downloads/index.html

Step 2: Click on “Downloads” link and select “JDK Download”.

Selenium Java Download

Step 3: Select “Accept License Agreement” radio button.

Selenium_Java_Download_Accept

Step 4: Select the appropriate installation. Click the appropriate link and save the .exe file to your disk.

Selenium_Java_Download2

Step 5: Run the downloaded .exe file to launch the Installer wizard. Click ‘Next’ to continue.

Selenium_Java_install_1

Step 6: Select the appropriate features and click ‘Next’.

Selenium_Java_install_2

Step 7: The installer is extracted files and its progress is shown in the wizard.

Selenium_Java_install_3

Step 8: The user can choose/modify the install location and click ‘Next’.

Selenium_Java_install_4

Step 9: The installer installs the JDK and new files are copied.

Selenium_Java_install_5

Step 10: The Installer installs successfully and displays the same. Click the close button.

Selenium_Java_install_6

 

Step 11: To verify if the installation was successful, go to the command prompt and just type ‘java’ as a command. The output of the command is shown below. If the Java installation is unsuccessful or if it had NOT been installed, it would throw an “unknown command” error.

Selenium_Java_install_7

Download and Configure Eclipse

Step 1: Navigate to the URL: http://www.eclipse.org/downloads/ and download the appropriate file based on your OS architecture.

Selenium_eclipse-3

Step 2: Click the ‘Download’ button.

Selenium_eclipse-4

 

Step 3: The download would be in a Zipped format. Unzip the contents.

Selenium_eclipse-5

Step 4: Locate Eclipse.exe and double click on the file.

Selenium_eclipse-6

Step 5: To configure the workspace, select the location where the development has to take place.

Selenium_eclipse-7

Step 6: The Eclipse window opens as shown below.

Selenium_eclipse-8

Step 7: In Eclipse, select Windows > Preferences > Java -> Installed JREs

Selenium_eclipse-9

Step 8:  Make sure under the name field your jre checkbox should be checked.

Step 9:  Close the preferences dialog.

Step 10:  We are done with the one time setup.

Configure Selenium WebDriver

Download the Selenium Java Client Libraries

As we would be using Java as the programming language for this series and in order to create test scripts in java, we would have to introduce language- specific client drivers. Thus, let us begin with the downloading of Selenium Java Client Libraries.

Step 1: Navigate to the selenium downloads section http://www.seleniumhq.org/download/and download Selenium WebDriver by clicking on its version number as shown below.

Selenium_eclipse-webdriver-1

Step 2: The downloaded file is in Zipped format and one has to unzip the contents to map it to the project folder.

Selenium_eclipse-webdriver-2
Step 3: The Unzipped contents would be displayed as shown below.

Selenium_eclipse-webdriver-3

Configuring Libraries with Eclipse IDE

Step 1: Open Eclipse by cli. Create a new java based project following File -> New -> Java Project. Refer the following figure for the same.

Selenium_eclipse-webdriver-4

Step 2: Provide a user defined name for your Java Project. Let us provide the name as Selenium_Project and Click on the Finish Button. The newly created project can be viewed at the left side of the screen in the package explorer panel.

Step 3: Create a new Java class named as “First_WebdriverClass” under the source folder by right clicking on it and navigating to New -> class.

Step 4: Now let us configure the libraries into our Java project. For this, select the project and Right click on it. Select “Properties” within the listed options. The following screen appears, Select “Java Build Path” from the options.

Selenium_eclipse-webdriver-5
Step 5: By default, “Libraries” tab is opened. If not, click on the “Libraries” tab. Then, click on the “Add External Jars…” button. Browse to the location where we have saved the extracted folder for Java Client Libraries.

Step 6: Select all the JAR files present in the “selenium-java-2.42.2” folder and click on open button within the dialog box. The properties dialog box should look like the below illustration.

Selenium_eclipse-webdriver-6

Step 7: Click on the “OK” button within the dialog box so as to complete the configuration part of Selenium Libraries in our java project.

 

Leave a Reply

Your email address will not be published. Required fields are marked *