How to setup Selenium web driver with eclipse.

 Setup Selenium web driver with eclipse.

In this selenium web driver tutorial, We are going to focus on how to setup selenium web driver with Eclipse. how to download selenium API and integrate with eclipse. before this we need to install java and eclipse for selenium web driver please follow the link Install java and eclipse. To Configure Java and eclipse at your machine.

Download the latest version of selenium API from the link ->https://docs.seleniumhq.org/download/

Here you can see the latest version is 3.12.0 at the time of writing this tutorial. I recommended you always go with the latest version.

What is selenium API: 

In simple word, selenium automates browsers. Selenium is an open-source automated testing tool for web applications for different browsers like chrome and firefox and platforms. selenium is the suite of different tools like. web driver, Selenium remote control, Selenium Grid.

If we talk about the history of the selenium or the developers who develop the selenium. At very first In 2004 selenium develop by Jason Huggins, selenium RC develop by Paul Hammant, Selenium Grid develop by Patrick Lightbody, Selenium IDE developed by Shinya Kasatani, Selenium web driver developed by Simon Stewart. So here is the complete team behind the scene who develop the really beautiful tool and make automation easy.

Setup Web driver and browser API

Download Latest version of chrome driver. download chrome driver

Setup Web driver and browser APINote: Choose all the API according to your system configuration Like if you are using window download the ZIP for the window or If you are using Linux download the ZIP for Linux and so on.

Why we need chrome driver or any browser driver here.

Browsers implement the web driver protocol by using this chromedriver.exe. browser driver start a server at your machine type of servers is depends on your browser like if you are using chrome browser driver then it will start a standalone server and the browser’s driver help to selenium to communicate with the browser.

Add selenium API in your project

After download all the API now you need to configure these API inside your working project. Below is the simple steps that you need to follow.

Create a new java project in eclipse.

File->New->java project

Right click on the project and click on properties at the bottom.

Setup Web driver and browser API

Select API from your location.

Setup Web driver and browser API

Test your configuration Create a class and try to execute below script.

Write the first web automation Test script with selenium web driver.

package com.SeleniumEasyTestCases;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;

public class SeleniumWithCodebun {
  
  static WebDriver driver;
  
  public static void main(String args[]){
    
    System.setProperty("webdriver.chrome.driver", "C:\\chromedriver.exe");
    driver=new ChromeDriver();
    driver.manage().window().maximize();
    driver.get("http://www.seleniumeasy.com/test/");
    driver.close();
  }

}

NOTE:  System.setProperty(“webdriver.chrome.driver”, “C:\\chromedriver.exe”);

You need to set the path of chromedriver.exe according to the location.

Code explain line by line for selenium web automation script.

 Inside this System.setProperty() we need to pass browser driver accordingly in as a first parameter and the path of the driver in the second parameter.

System.setProperty("webdriver.chrome.driver", "C:\\chromedriver.exe");

Create a new instance of Chrome Driver here I am going to create the script for chrome browser you can change this instance depends on the browser you are going to use.

WebDriver driver=new ChromeDriver();

To maximize the browser window.

 driver.manage().window().maximize();

For target URL pass URL in the get method, it will open the browser and pass the link in the URL.

driver.get("http://www.seleniumeasy.com/test/");

Close browser.

driver.close();

 

 

Add a Comment

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