简体   繁体   中英

Problem when try to run Selenium Test on Ubuntu

I trying to run easy selenium test under Ubuntu

@Test
public void openGoogle() {
    WebDriver driver = new ChromeDriver();
    driver.get("https://google.com");
    driver.quit();
}

but every single time I run it I am getting that error message:

      com.google.common.base.Preconditions.checkState(ZLjava/lang/String;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)V
        java.lang.NoSuchMethodError: com.google.common.base.Preconditions.checkState(ZLjava/lang/String;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)V
            at org.openqa.selenium.remote.service.DriverService.findExecutable(DriverService.java:125)
            at org.openqa.selenium.chrome.ChromeDriverService.access$000(ChromeDriverService.java:35)
            at org.openqa.selenium.chrome.ChromeDriverService$Builder.findDefaultExecutable(ChromeDriverService.java:159)
            ...

I have tried to change my build.gradle but It does not work. Anyone meet same the problem when running Selenium tests?

Selenium can't find driver executable. You need to set path.

Check here

https://github.com/SeleniumHQ/selenium/issues/3880

I have updated test like that but it still does not work. What kind of problems can couse that kind of errors?

@Test
public void openGoogle() {
    System.setProperty("webdriver.chrome.driver", "/home/user/projects/chromedriver");
    WebDriver driver = new ChromeDriver();
    driver.get("https://google.com");
    driver.quit();
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM