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

public class Locators {

public static void main(String ars[]) throws InterruptedException {
    
    WebDriver driver = new ChromeDriver();
    
    driver.manage().window().maximize();
    driver.get("https://www.google.com");
    Thread.sleep(5000);
    driver.close();
}

}

Getting this error...

>     Exception in thread "main" java.lang.IllegalStateException: The path to the driver executable The path to the driver executable

must > be set by the webdriver.chrome.driver system property; for more > information, see > https://github.com/SeleniumHQ/selenium/wiki/ChromeDriver. The latest > version can be downloaded from > http://chromedriver.storage.googleapis.com/index.html > at org.openqa.selenium.internal.Require$StateChecker.nonNull(Require.java:280) > at org.openqa.selenium.remote.service.DriverService.findExecutable(DriverService.java:142) > at org.openqa.selenium.chrome.ChromeDriverService.access$000(ChromeDriverService.java:37) > at org.openqa.selenium.chrome.ChromeDriverService$Builder.findDefaultExecutable(ChromeDriverService.java:222) > at org.openqa.selenium.remote.service.DriverService$Builder.build(DriverService.java:419) > at org.openqa.selenium.chrome.ChromeDriverService.createDefaultService(ChromeDriverService.java:119) > at org.openqa.selenium.chrome.ChromeDriver.(ChromeDriver.java:41) > at Selenium.SeleniumPrograms.Locators.main(Locators.java:10)

cruisepandey
  • 28,520
  • 6
  • 20
  • 38

1 Answers1

1

yes you need to. Executable should be available to selenium to perform UI operations.

// Configuring the system properties of chrome driver
System.setProperty("webdriver.chrome.driver", "C:\\Selenium-java\\chromedriver_win32chromedriver.exe"); 

This may not be required for Firefox. see this here

cruisepandey
  • 28,520
  • 6
  • 20
  • 38