selenium installation tutorial

Selenium Installation Tutorial – Why we should use Selenium for Automation Testing?

Selenium installation tutorial! Being a Software Tester we hear much about Automation and Selenium so this tutorial is entry level of your Automation learning. Selenium is used for Website Automation and it helps to perform all the browser related operation. It can be used for clicking on web element, filling form, switching to different windows, mouse hover, drag and drop operations and many more including every complex operation of web application. So, if you are Software tester, QA (Quality Analyst or Quality Assurance Engineer) this tutorial will be a lot worth it.


In this tutorial, we will guide you to complete Selenium set up and also write first selenium project or script. This tutorial will be explaining each step with a clear snapshot which will help you to do this set up independently & with ease.

Pre Requisites for Selenium Framework:

  • One Machine with 32 bit or 64 bit operating system and min RAM 4 GB
  • Java should be Installed
  • Eclipse or any other IDE should be installed on your machine (We will be using Eclipse for this tutorial)

Also Read: Selenium Interview Questions

How to check Java version in cmd?

Java should be installed on machine.
Steps to check Java Installation: Open command prompt and type “java -version” and enter.

java version in cmd

Note:

If java is not installed on your machine then and want to setup java then follow this tutorial- Step by Step Java Installation & Setup

Steps to Install Selenium in Windows:

  • Step 1: Go to Desktop and click on Eclipse icon to open eclipse
Eclipse
  • Step 2: Select workspace

Now, it will open it with default workspace but if you are opening eclipse ide for the first time it will ask for workspace. Then, you have to give one folder path as workspace.

Eclipse launcher

Create Selenium Java Project:

  • Step 3: Create Selenium Project (similar to Java Project):

Go to File> New and click on Java Project

Eclipse Java New Project
  • Step 4: Enter Project Details:

Enter Project Name, ensure correct JRE selected and click on Finish to create your Project.

New Java Project Details

Also Read: Katalon Studio and Selenium Detailed Comparison

Selenium roject navigation panel

Add Selenium Jar in Java Project:

  • Step 5: Download Selenium Jar:

Selenium is responsible for all the browser operations so you need to download from Selenium website. Although Selenium released different version we have to choose the latest stable version also our installed version should be compatible with selenium. Here are steps to download Chrome Driver.

  • Go to selenium website https://www.selenium.dev/downloads/ and download the latest Jar and save on your machine.

Direct download link: https://bit.ly/2TlkRyu

Selenium Server Download
  • Save on your machine
Save Selenium Jar
  • Add Selenium Jar in your above Project- Configure and Build your project with Selenium Jar.
  • Go to Eclipse and right-click on automation Project
  • Move the mouse to “Build Path” and go and click on “Configure Build Path”. Refer below for hint:
Configure Build Path
  • Browse above downloaded selenium jar (Step 5)
Selenium Jar
  • Click on Open to add jar.
Add Jar
  • Click on Apply and close. Now selenium jar added into your project.
Selenium Jar

Download Chrome Driver for Selenium:

  • Download Chrome Driver as per your browser version:
  • Check chrome version: Open Chrome and go to the right corner, click in three dots, navigate to “Help” ad click on “About Google Chrome” and check the browser version.
Chrome version
  • Download Chrome Driver exe from below link and navigate to a new window and save Chrome Driver zip file on your machine:

https://chromedriver.chromium.org/downloads

Chrome driver version
  • Save Chrome Driver zip file and then Unzip the file to a location
Chrome driver zip file
  • Step 6: Go to Project and right-click on the src folder and create a test package.
Create package
  • Step 7: Go to test package create LoginTest class
Create class

First Selenium Webdriver Script in Java:

  • Step 8: Write your first selenium test
package test;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
public class LoginTest {
	public static void main(String[] args) {
		// set system property with ChromeDriver
		System.setProperty("webdriver.chrome.driver", "C:\\Users\\ajit"
				+ "\\Desktop\\NewCode\\SeleniumJars\\chromedriver.exe");
		//Create WebDriver instance
		WebDriver driver = new ChromeDriver();
		// driver.get method used to naviagte to website
		driver.get("http://newtours.demoaut.com/");
		// maximize browser size
		driver.manage().window().maximize();
		//Print Website Title
		System.out.println("website title: "+driver.getTitle());
		// Close Browser
		driver.close();
		
	}
}
Selenium first test script
  • Step 9: Run your test and you will see browser will open and website printed on the console.

Console output:

Output

Also Read: Install Java & Setup Environment Variable

Congratulations!! Now, you went through the Selenium installation tutorial, you can automate any website using selenium. Still if you face any issue in above steps then feel free to contact us. For more learning explore our other blogs. Also we are looking for your feedback and suggestions

Write A Comment