gpt4 book ai didi

maven - 在 Maven 项目中使用 WebDriverManager 运行 ChromeDriver 时出现异常

转载 作者:行者123 更新时间:2023-12-01 09:39:00 24 4
gpt4 key购买 nike

尝试在 Maven 项目中使用 WebDriverManager 打开 ChromeDriver 时出现异常。

我计划的框架倾向于在 pom.xml 中添加依赖项后从 WebDriverManager 中提取 ChromeDriver,并打算使用 Gauge 执行测试。

在运行测试时尝试为 ChromeDriver 创建新实例时发生错误。

这是异常(exception):

 Error Message: java.lang.NoSuchMethodError: com.google.common.util.concurrent.SimpleTimeLimiter.create(Ljava/util/concurrent/ExecutorService;)Lcom/google/common/util/concurrent/SimpleTimeLimiter;
Stacktrace:
org.openqa.selenium.net.UrlChecker.<init>(UrlChecker.java:64)
org.openqa.selenium.remote.service.DriverService.waitUntilAvailable(DriverService.java:187)
org.openqa.selenium.remote.service.DriverService.start(DriverService.java:178)
org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:78)
org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:646)
org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:255)
org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:237)
org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:138)
org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:178)
org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:167)
org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:124)
StepTests.setupTest(StepTests.java:26)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
java.lang.reflect.Method.invoke(Unknown Source)
com.thoughtworks.gauge.execution.MethodExecutor.execute(MethodExecutor.java:38)
com.thoughtworks.gauge.execution.HooksExecutor$TaggedHookExecutor.executeHook(HooksExecutor.java:102)
com.thoughtworks.gauge.execution.HooksExecutor$TaggedHookExecutor.execute(HooksExecutor.java:88)
com.thoughtworks.gauge.execution.HooksExecutor.execute(HooksExecutor.java:45)
com.thoughtworks.gauge.processor.MethodExecutionMessageProcessor.executeHooks(MethodExecutionMessageProcessor.java:65)
com.thoughtworks.gauge.processor.SpecExecutionStartingProcessor.process(SpecExecutionStartingProcessor.java:32)
com.thoughtworks.gauge.connection.MessageDispatcher.dispatchMessages(MessageDispatcher.java:89)
com.thoughtworks.gauge.GaugeRuntime.dispatchMessages(GaugeRuntime.java:104)
com.thoughtworks.gauge.GaugeRuntime.access$100(GaugeRuntime.java:36)
com.thoughtworks.gauge.GaugeRuntime$2.run(GaugeRuntime.java:85)
java.lang.Thread.run(Unknown Source)

运行此代码时:
import com.thoughtworks.gauge.*;
import io.github.bonigarcia.wdm.ChromeDriverManager;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import com.thoughtworks.gauge.Step;
import static org.junit.Assert.assertEquals;


public class StepTests {
//Holds the WebDriver instance
private WebDriver webDriver;

@BeforeSuite
public static void initializeDriver(){
ChromeDriverManager.getInstance().setup();
}

@BeforeSpec
public void setupTest(){
webDriver = new ChromeDriver();
}

--test code--



@AfterSuite
public void closeDriver(){
if (webDriver != null) {
webDriver.quit();
}
}
}

如果您需要了解更多信息才能找到解决方案,请通知我。

最佳答案

您在 Guava 中存在版本冲突。 Selenium WebDriver(不是 WebDriverManager)依赖于给定版本的 Guava,看起来你在你的项目中使用另一个版本。我会使用两者的最新版本。

关于maven - 在 Maven 项目中使用 WebDriverManager 运行 ChromeDriver 时出现异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46222461/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com