I've created a new Java project using Selenium and Maven. This is the relevant content in pom.xml
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>2.45.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-chrome-driver -->
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-chrome-driver</artifactId>
<version>3.8.1</version>
</dependency>
</dependencies>
I then created this basic Java program that uses Selenium framework:
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
public class Start {
public static void main(String[] args) {
// declaration and instantiation of objects/variables
System.setProperty("webdriver.firefox.marionette", "D:\\geckodriver.exe");
WebDriver driver = null;
try {
driver = new FirefoxDriver();
String baseUrl = "https://www.google.co.in/";
driver.get(baseUrl);
} finally {
driver.close();
}
}
}
However, I'm getting this compilation error:
The type org.openqa.selenium.internal.Killable cannot be resolved. It is indirectly referenced from required .class files
Can someone pls suggest where am I going wrong?
Remove this dependency from pom.xml:
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-chrome-driver</artifactId>
<version>3.8.1</version>
</dependency>
You are using a vesrion 2.45.0 of Selenium java bindings (published on February 2015):
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>2.45.0</version>
</dependency>
If you examine compile dependencies of the above package: https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java/2.45.0
you will see that this package depends on selenium-chrome-driver 2.45.0 package. Maven will resolve this dependency automatically during compilation, so you don't need to declare this package in the pom.xml. file.
But if you declare this package selenium-chrome-driver as a dependency directly in the pom.xml file, using different version (the newest 3.8.1), then maven will be using this version 3.8.1 instead of 2.45.0 during compilation, and this will cause the error - wrong, incompatibile jar library is used.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With