java.lang.NoSuchMethodError: com.google.common.base.Preconditions.checkArgument(ZLjava/lang/String;I)V 与 IE 和 Selenium 通过 Java [英] java.lang.NoSuchMethodError: com.google.common.base.Preconditions.checkArgument(ZLjava/lang/String;I)V with IE and Selenium through Java

查看:29
本文介绍了java.lang.NoSuchMethodError: com.google.common.base.Preconditions.checkArgument(ZLjava/lang/String;I)V 与 IE 和 Selenium 通过 Java的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将 selenium 与 sikuli 一起使用.所以 sikuli 不会使用当前的 java 设置在 64 位上运行,因此在我的项目中将运行时更改为指向 32 位运行时环境并使用 32 添加了我的 selenium jar有点 iewebdriver 现在我有上面的问题 查看网络上的每个地方都添加了 guava.jar 文件 v.21 它没有解决问题将其更改为 guava 26jre.jar 仍然没有任何工作这里是我的代码和错误如果有人能发现我哪里出错了

I am trying to use selenium with sikuli.So sikuli would not run on a 64 bit using the current java set up so in my project changed the runtime to point to a 32 bit runtime environment and added my selenium jars using the 32 bit iewebdriver now I have a problem with the above Looked every where on the net added the guava.jar file v.21 it did not solve the problem changed that to the guava 26jre.jar and still nothing is working here is my code and errors if anyone can spot where I am going wrong

错误

Exception in thread "main" java.lang.NoSuchMethodError: com.google.common.base.Preconditions.checkArgument(ZLjava/lang/String;I)V
at org.openqa.selenium.remote.service.DriverService$Builder.usingPort(DriverService.java:285)
at org.openqa.selenium.ie.InternetExplorerDriver.setupService(InternetExplorerDriver.java:242)
at org.openqa.selenium.ie.InternetExplorerDriver.<init>(InternetExplorerDriver.java:211)
at org.openqa.selenium.ie.InternetExplorerDriver.<init>(InternetExplorerDriver.java:150)
at riOSikuliAutomation.RiOSikuliAutomation.main(RiOSikuliAutomation.java:33)

这是我的代码

DesiredCapabilities cap = DesiredCapabilities.internetExplorer();
cap.setCapability("nativeEvents", false);
cap.setCapability("unexpectedAlertBehaviour", "accept");
cap.setCapability("ignoreProtectedModeSettings", true);
cap.setCapability("disable-popup-blocking", true);
cap.setCapability("enablePersistentHover", true);
cap.setCapability("ignoreZoomSetting", true);
cap.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS,true);
InternetExplorerOptions options = new InternetExplorerOptions();
options.merge(cap);
System.setProperty("webdriver.ie.driver", "C:\Users\Selenium\IEDriverServer.exe");
WebDriver driver = new InternetExplorerDriver(options);

只要读到最后一行,错误就会弹出,有什么我做错的地方请指教?

as soon as it reads the last line the error pops up, anything I am not doing right please advise ?

推荐答案

此错误信息...

java.lang.NoSuchMethodError: com.google.common.base.Preconditions.checkArgument(ZLjava/lang/String;I)V

...暗示 IEDriverServer 无法启动/生成新的 WebBrowsing 会话,即 InternetExplorer 浏览器 会话.

...implies that the IEDriverServer was unable to initiate/spawn a new WebBrowsing Session i.e. InternetExplorer Browser session.

您的主要问题是您使用的二进制文件版本之间的不兼容,如下所示:

Your main issue is the incompatibility between the version of the binaries you are using as follows:

  • 您提到过使用 guava-21.0-jre.jar,这是非常古老的.
  • You have mentioned about using guava-21.0-jre.jar which is pretty ancient.

您的问题的解决方案是以下任一/所有步骤:

Solution to your question would be either/all of the following steps:

  • Selenium 升级到当前级别版本 3.14.0 包括 guava-25.0-jre.
  • Guava 升级到当前的 26.0-jre 级别(根据 Selenium v​​3.14.0 Java 客户端).

  • Upgrade Selenium to current levels Version 3.14.0 which includes guava-25.0-jre.
  • Upgrade Guava to current levels of 26.0-jre (as per Selenium v3.14.0 Java clients).

  • Maven 依赖如下:

  • Maven Dependency is as follows:

<!-- https://mvnrepository.com/artifact/com.google.guava/guava -->
<dependency>
    <groupId>com.google.guava</groupId>
    <artifactId>guava</artifactId>
    <version>26.0-jre</version>
</dependency>

确保您的依赖树中没有多个版本.

Ensure you don't have several versions in your dependency tree.

  • 要通过 Maven 查找现有的番石榴版本,请使用以下命令:

  • To look for the existing guava versions through Maven use the command:

mvn dependency:tree | less

清理您的项目工作区,通过您的IDE重建您的项目,仅使用所需的依赖项.

Clean your Project Workspace through your IDE and Rebuild your project with required dependencies only.

这篇关于java.lang.NoSuchMethodError: com.google.common.base.Preconditions.checkArgument(ZLjava/lang/String;I)V 与 IE 和 Selenium 通过 Java的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆