In the previous guide, we introduced the fundamental architecture and features of WebDriver. This is the 9th guide in the Selenium Tutorial Training Series.
In this guide, we will discuss the process of installing and setting up WebDriver from scratch. We will also explore the different drivers provided by WebDriver, each designed for specific testing and environmental requirements.
Recommended IPTV Service Providers
- IPTVGREAT – Rating 4.8/5 ( 600+ Reviews )
- IPTVRESALE – Rating 5/5 ( 200+ Reviews )
- IPTVGANG – Rating 4.7/5 ( 1200+ Reviews )
- IPTVUNLOCK – Rating 5/5 ( 65 Reviews )
- IPTVFOLLOW -Rating 5/5 ( 48 Reviews )
- IPTVTOPS – Rating 5/5 ( 43 Reviews )
In order to use WebDriver for scripting, there are certain prerequisites that need to be in place, such as the basic environment setup. In this series, we will be using Java as our programming language for the examples. So, let’s start with the installation of Java.
What You Will Learn:
Java Installation
Step 1: Visit the official Oracle site – “JAVA download”, and download Java Platform, Standard Edition. You can find all the recent releases on the page.
Step 2: After clicking on the Download button, you will see the following screen. Accept the License agreement and choose the appropriate Java Development Kit (JDK) from the options based on your system configuration.
Make sure to download the JDK (Java Development Kit) as it already includes the JRE (Java Runtime Environment) and there is no need to install the JRE separately.
Eclipse IDE Installation
Step 1: Go to the Eclipse official website and visit the download page – Eclipse download. You can find all the recent releases on the page.
Make sure to choose and download the appropriate Eclipse IDE for Java EE developers based on your system configuration. There are separate download links available for 64-bit and 32-bit Windows operating systems.
Step 2: After clicking on the download link, you will be redirected to a page providing information about the current download. Click on the download icon to proceed.
Wait for a few minutes until the complete zip folder is downloaded.
Step 3: Once downloaded, copy the folder and place it in your desired location on the file system.
Step 4: Extract the zipped folder to find the “eclipse” folder, which contains all the necessary application and source files.
Step 5: Launch the Eclipse IDE by running “eclipse.exe” from the “eclipse” folder. Refer to the above illustration for guidance.
Step 6: The application will prompt you to specify the workspace location, which is where all your Eclipse projects will be stored. Enter/browse the desired location or use the default location, then click the OK button.
Configuring WebDriver
Since we are using Java as the programming language for this series and need to create test scripts in Java, we need to download the language-specific client drivers. Let’s start by downloading the Selenium Java Client Libraries.
Download the Selenium Java Client Libraries
Step 1: Visit Selenium’s official website and go to the download page – “http://docs.seleniumhq.org/download/”. Look for the section listing the Client Libraries available for different programming languages. Click on the download link for Java Client Library.
Wait for a few minutes until the complete zipped folder is downloaded.
Step 2: Once downloaded, copy the folder and place it in your desired location on the file system.
Step 3: Extract the zipped folder to find the folder named “Selenium-2.41.0.zip”. This folder contains all the necessary jar files required for creating test scripts in Java.
These libraries can be configured in Eclipse IDE.
Configure Libraries with Eclipse IDE
Step 1: Open Eclipse IDE. Create a new Java project by selecting File -> New -> Java Project. Refer to the following figure for guidance.
Step 2: Give a name to your Java Project. Let’s name it “Learning_Selenium” and click the Finish button. The newly created project will be displayed on the left side of the screen in the package explorer panel.
Step 3: Create a new Java class named “First_WebdriverClass” under the source folder by right-clicking on it and navigating to New -> class.
Step 4: Now we need to configure the libraries in our Java project. Right-click on the project, select “Properties” from the list of options, and choose “Java Build Path” from the following screen.
Step 5: The “Libraries” tab will be opened by default. If not, click on the “Libraries” tab. Then, click on the “Add External Jars…” button. Browse to the location where you saved the extracted folder for Java Client Libraries.
Step 6: Select all the JAR files in the “selenium-java-2.41.0” folder and click the open button in the dialog box. The properties dialog box should resemble the following illustration.
Step 7: Click the “OK” button in the dialog box to complete the configuration of Selenium Libraries in our Java project.
Your project will now look like this:
Available Drivers
WebDriver provides a variety of driver classes, each intended for a specific web browser. Each browser has its own driver implementation in WebDriver.
While some browsers can be automated directly in WebDriver, others require an external entity, known as a Driver Server, to automate and execute test scripts. To use different web browsers, the user needs to download the corresponding Driver Server.
Note that each web browser has its own dedicated Driver Server, and a Driver Server cannot be used with browsers other than the one it is designed for.
Below is the list of available web browsers and their corresponding Server Drivers.
Conclusion
In this guide, we have covered all the necessary steps for setting up the environment and installing the required components to create WebDriver test scripts.
Here are the main points discussed in this guide:
- Before creating WebDriver-based test scripts, some utilities and packages need to be installed.
- Install JDK (Java Development Kit), which already includes JRE (Java Runtime Environment).
- Download Eclipse IDE, and no additional installation is required.
- Download Java Client Libraries to write test scripts in Java.
- Launch Eclipse IDE and select the workspace where projects will be stored.
- Create a new Java project in Eclipse and add a Java class to it.
- Configure Eclipse by importing the jar files for Java Client Drivers.
- Some web browsers can be automated directly, while others require a Driver Server.
- Firefox and HTML Unit are the only browsers that can be automated directly without a separate Driver Server. Other browsers like Chrome, Safari, and Internet Explorer require their respective Driver Servers.
Next Tutorial #10 => Now that we have completed the entire setup and installation, in the next guide, we will create our own WebDriver test script using Java.
Note for readers: While we work on the next tutorial in the Selenium Tutorial Series, please install the packages mentioned in this guide and the required utilities to get started. Most of the WebDriver-related packages can be found on Selenium’s official website.
Let us know if you encounter any issues during the installation process.