2

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

error

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)

and here is my code

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 ?

my dependencies

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
Tim
  • 206
  • 6
  • 16

2 Answers2

1

This error message...

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

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

  • You have mentioned about using guava-21.0-jre.jar which is pretty ancient.

Solution

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

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

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

  • If issue still persists delete the MAVEN_HOME directory .m2 and download the binaries afresh.
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
0

I met the same problem, however the actual reason is that I used com.google.collections#google-collections and com.google.guava#guava at the same time in my project, which both declared class com.google.common.base.Preconditions, and result into a confliction.

Class defination confliction is a really annoying problem in java project.

Here I recommend a EASY TO USE toolkit arthas, you can find wihch jar is used when loading a class, or dump the real using bytecode in JVM into a .class file with it.

Liu Hao
  • 511
  • 5
  • 10