Skip to main content

Command Palette

Search for a command to run...

Selenium Locators How to run Selenium tests on Chrome using ChromeDriver?

Published
1 min read
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;

public class Max {

public static void main(String args[]) throws InterruptedException
{

System.setProperty("<Path of the ChromeDriver>");

ChromeOptions options = new ChromeOptions();
options.addArguments("start-maximized");

WebDriver driver = new ChromeDriver(options);

// Navigate to a website
driver.get("https://www.browserstack.com/")

//Close the browser
driver.quit();
} 
}

Code:

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;

public class Max {

public static void main(String args[]) throws InterruptedException
{
System.setProperty("<Path of the ChromeDriver>");
WebDriver driver = new ChromeDriver();

// Navigate to a website
driver.get("https://www.browserstack.com/");

//Mazimize current window
driver.manage().window().maximize();

//Delay execution for 5 seconds to view the maximize operation
Thread.sleep(5000);

//Close the browser
driver.quit();
} 
}

More from this blog

Development of net banking application

18 posts