Run First Test on Chrome Browser

Chrome browser implements the WebDriver protocol using an executable called ChromeDriver.exe. This executable starts a server on your system which will be responsible for running your test script in selenium.

Testcase: Open chrome browser and navigate to https://demoapp1.tequality.tech/ and close the browser

 

Step1: Right click on src folder and select New > Class

 

Step2: Provide Class Name and click on Finish

 

Step3: Open URL: https://sites.google.com/a/chromium.org/chromedriver/downloads in your browser and select any of the latest chrome driver version according to your browser version


Step4:
Download executable file as per the operating system you are working on.

For windows, click on the “chromedriver_win32.zip” download and unzip the file.

 


Step5:
Set a system property “webdriver.chrome.driver” to the path of your ChromeDriverServer.exe file and instantiate an ChromeDriver class.

Here below your test script will look like

 

import org.openqa.selenium.By;
import org.openqa.selenium.Cookie;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;

public class FirstChromeTest {

public static void main(String[] args) {

// System Property for Chrome Driver
System.setProperty("webdriver.chrome.driver", "E:\chromedriver.exe");

// Instantiate a ChromeDriver class.
WebDriver driver=new ChromeDriver();


//Maximize the browser window driver.manage().window().maximize();
driver.manage().window().maximize();


// Launch Website and navigate to URL
driver.get("https://demoapp1.tequality.tech/");

//close the browser
driver.close();

}

}


Step6: Run the code by right click on the Eclipse code and select Run As > Java Application