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

若如初见. 提交于 2019-12-17 20:33:08

问题


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


回答1:


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


来源:https://stackoverflow.com/questions/52594514/nosuchmethoderror-com-google-common-base-preconditions-checkstatezljava-lang-s

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!