IllegalAccessOSOS(Java)上新的ChromeDriver()抛出的错误

2022-09-02 13:13:11

在Eclipse下直接走出大门。

法典:

    System.setProperty("webdriver.chrome.driver" ,  "/path/to/selenium/chromedriver");
    WebDriver driver = new ChromeDriver();

引发异常:

Exception in thread "main" 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
    at org.openqa.selenium.net.UrlChecker.<init>(UrlChecker.java:67)
    at org.openqa.selenium.remote.service.DriverService.waitUntilAvailable(DriverService.java:190)
    at org.openqa.selenium.remote.service.DriverService.start(DriverService.java:181)
    at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:78)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:637)
    at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:250)
    at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:236)
    at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:137)
    at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:184)
    at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:171)
    at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:124)

OSX 10.12 硒 3.4 铬驱动程序 2.31


答案 1

将其设置回22.0对我有所帮助。

    <dependency>
        <groupId>com.google.guava</groupId>
        <artifactId>guava</artifactId>
        <version>22.0</version>
    </dependency>

答案 2

将其设置回22.0对我有所帮助。

版本22.0没有为我解决问题,但19.0解决了。

compile group: 'com.google.guava', name: 'guava', version: '19.0'

推荐