[英]Selenium test Java maven dependencies
I created tests on selenium ide.我在 selenium ide 上创建了测试。 I want to run java files on intellij idea.我想在 intellij idea 上运行 java 文件。 I prepared pom.xml like that but I have problem with running tests.我像这样准备了 pom.xml 但是我在运行测试时遇到了问题。
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>
When I run it, tests are failed当我运行它时,测试失败
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
What should I do to run it on Intellij Idea?我应该怎么做才能在 Intellij Idea 上运行它?
Use same selenium version for selenium-java, selenium-server etc. It will help you to prevent from any unexpected error对 selenium-java、selenium-server 等使用相同的 selenium 版本。它将帮助您防止任何意外错误
Change below to 3.141.59
as you are using in other dependency too with same version将以下更改为3.141.59
,因为您也在其他依赖项中使用相同版本
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.141.59</version>
</dependency>
Another thing you are getting error as below:另一件事你得到如下错误:
no such element: Unable to locate element: {"method":"css selector","selector":".ion-navicon"} (Session info: chrome=76.0.3809.132)没有这样的元素:无法找到元素:{"method":"css selector","selector":".ion-navicon"}(会话信息:chrome=76.0.3809.132)
That means your locator is not correct or it is not ready.这意味着您的定位器不正确或尚未准备好。 check your locator and add wait also before the element to locate检查您的定位器并在要定位的元素之前添加等待
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.