Selenium installation is a 3 steps process:
1. Install Java SDK.
2. Install Eclipse IDE.
3. Install Selenium Driver Files.
Step 1 – Install Java on your workstation.
Download and install the Java Software Development Kit (JDK) here
This JDK version comes bundled with Java Runtime Environment (JRE), so you do not need to download and install the JRE separately.
Why there is need to set JAVA_HOME?
Many Java based programs like Tomcat require JAVA_HOME to be set as environment variable to work correctly. Please note JAVA_HOME should point to a JDK directory not a JRE one. The point of setting the environment variable is to let programs know in which directory executables like javac can be found.
Steps to set JAVA_HOME
1. Open Advanced system settings
a. In windows 10 press Windows + Pause Key, this will open the system settings, click on Advanced system settings.
b. Now click on “Environment Variables”
c. Under “System Variables” click new and enter below details and save the changes.
d. Now scroll to “Path” under “System Variables” and click edit and add following location of java bin into that and save the changes.
e. Now after saving all the changes open command prompt windows + R and enter command “java -version” if you see below image that means environment variables are set properly for JAVA_HOME
Step 2 – Install Eclipse IDE.
Download latest version of "Eclipse IDE for Java Developers" here. Be sure to choose correctly between Windows 32 Bit and 64 Bit versions.
You should be able to download an exe file named "eclipse-inst-win64" for Setup.
Double-click on file to Install the Eclipse. A new window will open. Click Eclipse IDE for Java Developers.
After that, a new window will open which click button marked 1 and change path to "C:\eclipse". Post that Click on Install button marked 2
After successful completion of the installation procedure, a window will appear. On that window click on Launch.
This will start Eclipse for you.
Step 3 – Download the Selenium Java Client Driver.
You can download the Selenium Java Client Driver here. You will find client drivers for other languages there, but only choose the one for Java.
This download comes as a ZIP file named "selenium- 3.141.59.zip". For simplicity, extract the contents of this ZIP file on your C drive so that you would have the directory "C:\selenium-3.141.59\". This directory contains all the JAR files that we would later import on Eclipse.
Step 4 – Configure Eclipse IDE with WebDriver.
1. Launch the "eclipse.exe" file inside the "eclipse" folder that we extracted in step 2. If you followed step 2 correctly, the executable should be located on C:\eclipse\eclipse.exe.
2. When asked to select for a workspace, just accept the default location.
3. Create a new project through File > New > Java Project. Name the project as "SeleniumDemo".
A new pop-up window will open enter details as follow
1. Project Name
2. Location to save project
3. Select an execution JRE
4. Select layout project option
5. Click on Finish button
4. In this step,
1. Right-click on the newly created project and
2. Select New > Package, and name that package as "seleniumpackage".