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

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

问题描述

我正在尝试将sikuli与sikuli一起使用,因此sikuli无法使用当前的Java设置在64位上运行,因此在我的项目中将运行时更改为指向32位运行时环境,并使用32位添加了我的硒罐位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 Browser 会话.

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

您的问题的解决方案将是以下所有步骤之一或全部:

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

  • 升级到当前级别 版本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

清洁您的项目工作区重建您的项目,并且仅具有必需的依赖项.

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天全站免登陆