bonigarcia / webdrivermanager-examples

JUnit tests with Selenium WebDriver and WebDriverManager

Home Page:https://bonigarcia.dev/webdrivermanager/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error : java.lang.ClassNotFoundException: io.github.bonigarcia.wdm.WebDriverManager

bipinmnair89 opened this issue · comments

Using java version 1.8, Please update on how this issue can be resolved.

Error screenshots

WebDriverManagerError

WebDriverManager program

Complete error description

Exception in thread "main" java.lang.NoClassDefFoundError: io/github/bonigarcia/wdm/WebDriverManager
at com.InProgress.WebDriverManagerAPI.initializeMethod(WebDriverManagerAPI.java:17)
at com.InProgress.WebDriverManagerAPI.main(WebDriverManagerAPI.java:35)
Caused by: java.lang.ClassNotFoundException: io.github.bonigarcia.wdm.WebDriverManager
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 2 more

Hi,
I was able to solve the issue by removing the below line from the maven dependency as my code was present in the src folder and not in the test folder.

Line which was removed ----> test

Can you please share which line was removed @bipinmnair89 ?
Please find the below pom.xml + java sample code for the same.

Sample Code:

public static void main(String[] args) throws IOException
{
//setup the chromedriver using WebDriverManager
WebDriverManager.chromedriver().arch64().setup();

    //Create driver object for Chrome
    driver = new ChromeDriver();

    //Navigate to a URL
    driver.get("http://toolsqa.com");
    
    //close the browser
    driver.close();
}

pom.xml content:


4.0.0
ExtentReport
ExtentReport
0.0.1-SNAPSHOT

<dependencies>
	<!-- https://mvnrepository.com/artifact/org.testng/testng -->
	<dependency>
		<groupId>org.testng</groupId>
		<artifactId>testng</artifactId>
		<version>6.14.3</version>
		<scope>test</scope>
	</dependency>

	<dependency>
		<groupId>com.aventstack</groupId>
		<artifactId>extentreports</artifactId>
		<version>3.1.5</version>
	</dependency>


	<!-- https://mvnrepository.com/artifact/log4j/log4j -->
	<dependency>
		<groupId>log4j</groupId>
		<artifactId>log4j</artifactId>
		<version>1.2.17</version>
	</dependency>


	<!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java -->
	<dependency>
		<groupId>org.seleniumhq.selenium</groupId>
		<artifactId>selenium-java</artifactId>
		<version>3.141.59</version>
	</dependency>

	<dependency>
		<groupId>io.github.bonigarcia</groupId>
		<artifactId>webdrivermanager</artifactId>
		<version>3.0.0</version>
		<scope>test</scope>
	</dependency>

	<!-- https://mvnrepository.com/artifact/org.apache.commons/commons-io -->
	<dependency>
		<groupId>org.apache.commons</groupId>
		<artifactId>commons-io</artifactId>
		<version>1.3.2</version>
	</dependency>


</dependencies>
---------------------------- Error faced:

Exception in thread "main" java.lang.NoClassDefFoundError: io/github/bonigarcia/wdm/WebDriverManager
at takeScreenShot.TakeScreenShot_Demo.main(TakeScreenShot_Demo.java:24)
Caused by: java.lang.ClassNotFoundException: io.github.bonigarcia.wdm.WebDriverManager
at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:355)
at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
... 1 more


commented

Hope you got the issue resolved.

You need to comment this line, if your file is in src folder. If your file is in test folder then keep this line as it is.

io.github.bonigarcia webdrivermanager 4.0.0