'Selenium test Java maven dependencies
I created tests on selenium ide. I want to run java files on intellij idea. I prepared pom.xml like that but I have problem with running tests.
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?
Solution 1:[1]
Use same selenium version for selenium-java, selenium-server etc. It will help you to prevent from any unexpected error
Change below dependencies to the latest version as per today it is 4.1.3
. You can find the latest versions in this URL:
https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>4.1.3</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)
That means your locator is not correct or it is not ready. check your locator and add wait also before the element to locate
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 |