首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Selenium测试Java依赖项

Selenium测试Java依赖项
EN

Stack Overflow用户
提问于 2019-10-22 13:24:35
回答 1查看 3.7K关注 0票数 1

我创建了关于selenium ide的测试。我想在intellij上运行java文件。我准备了这样的pom.xml,但我在运行测试时遇到了问题。

代码语言:javascript
复制
dependencies>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.12</version>
        <scope>compile</scope>
    </dependency>
    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-server</artifactId>
        <version>3.141.59</version>
    </dependency>
    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>htmlunit-driver</artifactId>
        <version>2.33.2</version>
    </dependency>
    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-chrome-driver</artifactId>
        <version>3.141.59</version>
    </dependency>
    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-java</artifactId>
        <version>3.12.0</version>
    </dependency>
    <dependency>
        <groupId>io.github.bonigarcia</groupId>
        <artifactId>webdrivermanager</artifactId>
        <version>3.7.1</version>
    </dependency>
</dependencies>

当我运行它时,测试失败。

代码语言:javascript
复制
Starting ChromeDriver 2.41.578700 (2f1ed5f9343c13f73144538f15c00b370eda6706) on port 28288
Only local connections are allowed.
paź 22, 2019 3:17:24 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: OSS

org.openqa.selenium.NoSuchElementException: no such element: Unable to locate element: {"method":"css selector","selector":".ion-navicon"}
  (Session info: chrome=76.0.3809.132)
  (Driver info: chromedriver=2.41.578700 (2f1ed5f9343c13f73144538f15c00b370eda6706),platform=Linux 4.15.0-65-generic x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 0 milliseconds
For documentation on this error, please visit: https://www.seleniumhq.org/exceptions/no_such_element.html

我该怎么做才能在Intellij Idea上运行它呢?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-10-22 13:41:36

对selenium-java、selenium-server等使用相同的selenium版本。它将帮助您防止任何意外的错误。

将下面的依赖项更改为最新版本,就像现在的版本一样,它是4.1.3。您可以在此URL中找到最新版本:

https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java

代码语言:javascript
复制
<dependency>
    <groupId>org.seleniumhq.selenium</groupId>
    <artifactId>selenium-java</artifactId>
    <version>4.1.3</version>
</dependency>

另一件您正在收到的错误如下所示:

不存在这样的元素:无法定位元素:{“方法”:“css选择器”,“选择器”:“..ion Nav图标”}(会话信息: chrome=76.0.3809.132)

这意味着您的定位器不正确,或者它还没有准备好。检查您的定位器并在元素之前添加等待以查找

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/58505362

复制
相关文章

相似问题

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