Laura
Laura

Reputation: 63

NoSuchMethodError: com.google.common.base.Preconditions.checkState(ZLjava/lang/String;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)V

Getting the following error:

java.lang.NoSuchMethodError: com.google.common.base.Preconditions.checkState(ZLjava/lang/String;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)V

when running

System.setProperty("webdriver.chrome.driver", "/ocs/browserDrivers/chromedriver.exe");
//ChromeOptions chromeOptions = new ChromeOptions();
//chromeOptions.addArguments("start-maximized");
driver = new ChromeDriver();

Upgraded to selenium 3.14 and chromedriver 2.42.Not a maven project

enter image description here

Upvotes: 0

Views: 3491

Answers (1)

undetected Selenium
undetected Selenium

Reputation: 193088

This error message...

java.lang.NoSuchMethodError: com.google.common.base.Preconditions.checkState(ZLjava/lang/String;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)V

...implies that there was an error raised while executing the line:

System.setProperty("webdriver.chrome.driver", "/ocs/browserDrivers/chromedriver.exe");

Your main issue is the incompatibility between the WebDriver binary type and the underlying Operating System.

You need download, extract and use the right format of the WebDriver binary from chromedriver.storage for your program as follows:

  • Linux OS:

    chromedriver_linux64.tar.gz 2018-09-13 19:30:37 3.85MB
    
  • MAC OS:

    chromedriver_mac64.tar.gz   2018-09-13 18:14:11 5.75MB
    
  • Windows OS:

    chromedriver_win32.zip  2018-09-13 21:11:33 3.42MB
    

If you are using MAC OS so the System.setProperty() line would be:

System.setProperty("webdriver.chrome.driver", "/ocs/browserDrivers/chromedriver"); //drop the extension (.exe) part

If you are using Windows OS so the System.setProperty() line would be:

System.setProperty("webdriver.chrome.driver", "C:\\path\\to\\chromedriver.exe"); //mention the absolute path

Upvotes: 2

Related Questions