NoSuchMethodError: com.google.common.base.Preconditions.checkState(ZLjava/lang/String;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)V(NoSuchMethodError: com.google.common.base.Preconditions.checkState(ZLjava/lang/String;Ljava/lang/Object;Ljava/la
问题描述
得到以下错误:
java.lang.NoSuchMethodError: com.google.common.base.Preconditions.checkState(ZLjava/lang/String;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)V
运行时
System.setProperty("webdriver.chrome.driver", "/ocs/browserDrivers/chromedriver.exe");
//ChromeOptions chromeOptions = new ChromeOptions();
//chromeOptions.addArguments("start-maximized");
driver = new ChromeDriver();
升级到 selenium 3.14 和 chromedriver 2.42.不是 maven 项目
Upgraded to selenium 3.14 and chromedriver 2.42.Not a maven project
推荐答案
这个错误信息...
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");
您的主要问题是 WebDriver 二进制类型与底层操作系统之间的不兼容性.
Your main issue is the incompatibility between the WebDriver binary type and the underlying Operating System.
您需要从 WebDriver 二进制文件" rel="nofollow noreferrer">chromedriver.storage 为您的程序如下:
You need download, extract and use the right format of the WebDriver binary from chromedriver.storage for your program as follows:
Linux 操作系统:
Linux OS:
chromedriver_linux64.tar.gz 2018-09-13 19:30:37 3.85MB
MAC 操作系统:
MAC OS:
chromedriver_mac64.tar.gz 2018-09-13 18:14:11 5.75MB
Windows 操作系统:
Windows OS:
chromedriver_win32.zip 2018-09-13 21:11:33 3.42MB
如果您使用的是 MAC OS,那么 System.setProperty()
行将是:
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
如果您使用的是 Windows 操作系统,那么 System.setProperty()
行将是:
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
这篇关于NoSuchMethodError: com.google.common.base.Preconditions.checkState(ZLjava/lang/String;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)V的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:NoSuchMethodError: com.google.common.base.Preconditions.checkState(ZLjava/lang/String;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)V
基础教程推荐
- 减少 JVM 暂停时间 >1 秒使用 UseConcMarkSweepGC 2022-01-01
- 无法使用修饰符“public final"访问 java.util.Ha 2022-01-01
- 降序排序:Java Map 2022-01-01
- Java:带有char数组的println给出乱码 2022-01-01
- 如何使用 Java 创建 X509 证书? 2022-01-01
- “未找到匹配项"使用 matcher 的 group 方法时 2022-01-01
- Java Keytool 导入证书后出错,"keytool error: java.io.FileNotFoundException &拒绝访问" 2022-01-01
- 设置 bean 时出现 Nullpointerexception 2022-01-01
- 在 Libgdx 中处理屏幕的正确方法 2022-01-01
- FirebaseListAdapter 不推送聊天应用程序的单个项目 - Firebase-Ui 3.1 2022-01-01