我想知道是否有人可以告诉我为什么在使用 Selenium-Java 3.5.1 或更高版本时会出现以下错误 -
java.lang.IllegalAccessError: tried to access method com.google.common.util.concurrent.SimpleTimeLimiter.<init>(Ljava/util/concurrent/ExecutorService;)V from class org.openqa.selenium.net.UrlChecker
This error message...
java.lang.IllegalAccessError: tried to access method com.google.common.util.concurrent.SimpleTimeLimiter.<init>(Ljava/util/concurrent/ExecutorService;)V from class org.openqa.selenium.net.UrlChecker
...implies that there was a mismatch between the version of the WebDriver variant (ie GeckoDriver / ChromeDriver ) and the version of the respective WebBrowser variant (ie Firefox / Chrome ) you are using.
Note : You need to ensure that you are using the latest JDK versions.
If you are using GeckoDriver - Selenium - Firefox combo, you need to follow the following compatibility chart:
If you are using ChromeDriver - Chrome combo, you need to ensure that the binaries are compatible as per the entries below:
Note : A few months ago, Chromium Team made a preliminary announcement that ChromeDriver's versioning model will be changing. Now Chromium Team is moving forward with the plan. Specifically, ChromeDriver 2.46 will be the last release carrying the major version of 2. Future ChromeDriver releases will carry a version number similar to Chrome release. We will start with a release of ChromeDriver 73 next week, before the Beta release of Chrome 73.
Here is how the new release model will work:
Further, this error com.google.common.util.concurrent.SimpleTimeLimiter
was also observed when a Selenum Grid Node appears to have successfully registered to the Selenum Grid Hub and was also confirmed from the grid console but when requesting for a session the following error was observed :
org.openqa.selenium.WebDriverException: com.google.common.util.concurrent.SimpleTimeLimiter.create(Ljava/util/concurrent/ExecutorService;)Lcom/google/common/util/concurrent/SimpleTimeLimiter;
This error occured with Selenium-Grid-Extras Hub (1.12.16)
due to inconsistency between selenium and guava dependencies that are packaged into the JAR
This issue was addressed through the merge #367 and using Selenium v3.8.1 will solve your problem.
Ensure two points as :
In my earlier pom.xml, this was the entry:
<!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java -->
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>2.53.0</version>
</dependency>
Below error was being thrown,
Error: java.lang.IllegalAccessError: tried to access method com.google.common.util.concurrent.SimpleTimeLimiter.(Ljava/util/concurrent/ExecutorService;)V from class org.openqa.selenium.net.UrlChecker
Then I updated the POM with the latest version:
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.14.0</version>
</dependency>
I did not see the error once again. Hope this helps.
Check in you POM.XML file you will have 2 entry for "selenium-chrome-driver" dependency. so, both dependency there and it is confuse which one need to take and giving you Exception. My one is working after this change.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.