Reputation: 1
Hi I am beginner in Java selenium, i have problem in executing selenium standalone jar I am using eclipse version 4.15, JDk 14.0, selenium 3.14
error got Error occurred during initialization of boot layer java.lang.module.FindException: Unable to derive module descriptor for C:\Java-selenium\selenium-server-standalone-3.141.59.jar
package SeleniumPractice;
import org.openqa.selenium.chrome.ChromeDriver;//error importing org.openqa.selenium.chrome.ChromeDriver not accessible
public class launchBrowser {
public static void main(String[] args) {
//launch chrome browser
System.setProperty("webdriver.chrome.driver", "./driver/chromedriver.exe");
ChromeDriver driver = new ChromeDriver();//Error: cannot b resolved
}
}
Upvotes: 0
Views: 318
Reputation: 194
If you are importing a JAR package, then the folder containing the .jar
file has to be included in the CLASSPATH of your project. In this thread you can find instructions for setting a project classpath in Eclipse.
You should also consider using a package manager for managing dependencies, for example Maven. Eclipse provides great support for Maven, you can find details here. It is Ubuntu tutorial while you are probably using Windows, but everything important is the same here.
If you'll have any additional questions, comment this answer and I'll edit it accordingly.
In case you wanted to try Maven, I've attached an example of a pom.xml
file - configuration file for Maven projects - that I use for running Selenuim tests. To run the tests using this setup, you need to go to the folder with the pom.xml
file. In this folder run command mvn clean test
Before using the file, replace or remove:
com.example.your.domain
as groupIdyour-app-name
as artifactId,<repositories>
section (since I use a private repo for a few things)1.8
and Selenium is managed by TestNG framework, which is executed by Surefire plugin, you don't need this setup.<?xml version="1.0" encoding="UTF-8"?>
<project
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"
>
<modelVersion>4.0.0</modelVersion>
<groupId>com.example.your.domain</groupId>
<artifactId>your-app-name</artifactId>
<version>0.0.1-SNAPSHOT</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M5</version>
<configuration>
<suiteXmlFiles>
<suiteXmlFile>testng.xml</suiteXmlFile>
</suiteXmlFiles>
<properties>
<property>
<name>reporter</name>
<value>listenReport.Reporter</value>
</property>
</properties>
</configuration>
</plugin>
</plugins>
</build>
<!-- <repositories>
<repository>
You might have to add a custom repo.
</repository>
</repositories>-->
<dependencies>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.141.59</version>
</dependency>
</dependencies>
</project>
Upvotes: 1