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”.
Step 3: Select “Accept License Agreement” radio button.
Step 4: Select the appropriate installation. Click the appropriate link and save the .exe file to your disk.
Step 5: Run the downloaded .exe file to launch the Installer wizard. Click ‘Next’ to continue.
Step 6: Select the appropriate features and click ‘Next’.
Step 7: The installer is extracted files and its progress is shown in the wizard.
Step 8: The user can choose/modify the install location and click ‘Next’.
Step 9: The installer installs the JDK and new files are copied.
Step 10: The Installer installs successfully and displays the same. Click the close button.
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.
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.
Step 2: Click the ‘Download’ button.
Step 3: The download would be in a Zipped format. Unzip the contents.
Step 4: Locate Eclipse.exe and double click on the file.
Step 5: To configure the workspace, select the location where the development has to take place.
Step 6: The Eclipse window opens as shown below.
Step 7: In Eclipse, select Windows > Preferences > Java -> Installed JREs
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.
Step 2: The downloaded file is in Zipped format and one has to unzip the contents to map it to the project folder.
Step 3: The Unzipped contents would be displayed as shown below.
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.
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.
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.
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 Cancel reply