无法初始化Chrome硒驱动程序

时间:2020-11-04 02:43:58

标签: java selenium google-chrome

初始化chome驱动程序时出现以下错误。任何人都可以建议如何解决此问题。

我正在使用以下版本。

  • Java JDK11(最新版本)
  • 硒罐:3.141.59(最新版本)
  • Chrome 86.0.4240.183(正式版)(32位)
System.setProperty("webdriver.chrome.driver","C:\\chromedriver_win32\\chromedriver.exe"); 
2020-11-04 13:12:53.293 ERROR 1656 --- [nio-8080-exec-8] o.a.c.c.C.[.[.[/].[dispatcherServlet]    : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Handler dispatch failed; nested exception is java.lang.NoSuchMethodError: 'void com.google.common.base.Preconditions.checkState(boolean, java.lang.String, java.lang.Object, java.lang.Object, java.lang.Object)'] with root cause

java.lang.NoSuchMethodError: 'void com.google.common.base.Preconditions.checkState(boolean, java.lang.String, java.lang.Object, java.lang.Object, java.lang.Object)'
    at org.openqa.selenium.remote.service.DriverService.findExecutable(DriverService.java:134) ~[selenium-remote-driver-3.141.59.jar:na]
    at org.openqa.selenium.chrome.ChromeDriverService.access$000(ChromeDriverService.java:35) ~[selenium-chrome-driver-3.141.59.jar:na]
    at org.openqa.selenium.chrome.ChromeDriverService$Builder.findDefaultExecutable(ChromeDriverService.java:159) ~[selenium-chrome-driver-3.141.59.jar:na]
    at org.openqa.selenium.remote.service.DriverService$Builder.build(DriverService.java:355) ~[selenium-remote-driver-3.141.59.jar:na]
    at org.openqa.selenium.chrome.ChromeDriverService.createDefaultService(ChromeDriverService.java:94) ~[selenium-chrome-driver-3.141.59.jar:na]
    at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:123) ~[selenium-chrome-driver-3.141.59.jar:na]
    at au.com.optus.uam.AccountController.unlockUser(AccountController.java:47) ~[classes/:na]

我的POM.xml在下面

pom 1

pom 2

1 个答案:

答案 0 :(得分:1)

请在您的pom文件上添加依赖项,然后尝试运行

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