首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >为什么我不能使用Selenium和Java连接,使用Maven依赖呢?

为什么我不能使用Selenium和Java连接,使用Maven依赖呢?
EN

Stack Overflow用户
提问于 2021-12-23 09:28:33
回答 2查看 312关注 0票数 2

我正在尝试将seleium连接到maven java项目。我就会犯错。驱动程序已上载并在项目中找到。

我的Main.java

代码语言:javascript
运行
复制
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;

public class Main {
    public static void main(String[] args) throws Exception{
        System.setProperty("webdriver.gecko.driver", "C:\\Users\\Vlad\\IntellijIDEAProjects\\VKParser\\geckodriver.exe");

        WebDriver wd = new FirefoxDriver();
    }
}

而且我的依赖

代码语言:javascript
运行
复制
<dependencies>
    <dependency>
        <groupId>org.jsoup</groupId>
        <artifactId>jsoup</artifactId>
        <version>1.14.3</version>
    </dependency>

    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-java</artifactId>
        <version>LATEST</version>
    </dependency>
</dependencies>

我的错误

代码语言:javascript
运行
复制
Exception in thread "main" java.lang.NoSuchMethodError: 'int org.asynchttpclient.config.AsyncHttpClientConfigDefaults.defaultHashedWheelTimerTickDuration()'
    at org.openqa.selenium.remote.http.netty.NettyClient.<clinit>(NettyClient.java:56)
    at org.openqa.selenium.remote.http.netty.NettyClient$Factory.createClient(NettyClient.java:146)
    at org.openqa.selenium.remote.HttpCommandExecutor.<init>(HttpCommandExecutor.java:107)
    at org.openqa.selenium.remote.HttpCommandExecutor.<init>(HttpCommandExecutor.java:94)
    at org.openqa.selenium.remote.HttpCommandExecutor.<init>(HttpCommandExecutor.java:85)
    at org.openqa.selenium.remote.service.DriverCommandExecutor.<init>(DriverCommandExecutor.java:80)
    at org.openqa.selenium.firefox.FirefoxDriver$FirefoxDriverCommandExecutor.<init>(FirefoxDriver.java:142)
    at org.openqa.selenium.firefox.FirefoxDriver.toExecutor(FirefoxDriver.java:232)
    at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:186)
    at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:164)
    at Main.main(Main.java:25)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:78)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:567)
    at com.intellij.rt.execution.application.AppMainV2.main(AppMainV2.java:131)

我没做什么?

EN

Stack Overflow用户

发布于 2021-12-23 11:15:27

您可能希望使用最新的和稳定的Selenium-Java工件,如下所示:

代码语言:javascript
运行
复制
<!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java -->
<dependency>
    <groupId>org.seleniumhq.selenium</groupId>
    <artifactId>selenium-java</artifactId>
    <version>4.1.1</version>
</dependency>
票数 0
EN
查看全部 2 条回答
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/70460078

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档