Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
635 views
in Technique[技术] by (71.8m points)

java - 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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...