java.lang.NoSuchMethodError: com.google.common.base.Preconditions.checkState(ZLjava/lang/String;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)V
原因一:
没有设置chrome driver的位置
//设置driver位置的方法。
System.setProperty(“webdriver.chrome.driver”, “/Users/supinrong/code/driver/chromedriver”);
原因二:
guava版本冲突
The problem is that both dependencies depend on a different com.google.guava:guava
artifact.
In order to solve the error, you should explicitly depend on a single com.google.guava:guava
artifact. So go ahead and add the following in your build.gradle
:
compile 'com.google.guava:guava:27.0.1-jre'
将以下依赖项复制并粘贴到pom.xml中,然后进行Maven构建:
<!-- https://stackoverflow.com/questions/49021707/java-lang-nosuchmethoderror-com-google-common-base-preconditions-checkstatezlj?rq=1 -->
<!-- https://mvnrepository.com/artifact/com.google.guava/guava -->
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>27.1-jre</version>
</dependency>