Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
618 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 Answer

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...