Skip to content

HtmlUnitDriver : java.lang.NoClassDefFoundError: org/openqa/selenium/WrapsDriver  #6326

@pprraashant

Description

@pprraashant

Meta -

OS:
Windows 10
Selenium Version:
3.12.0
Browser:
HtmlUnitDriver

Browser Version:
Chrome - as per - System.out.println(driver.getBrowserVersion());

Expected Behavior -

we should able to click on web Element.

Actual Behavior -

https://www.google.com/?gws_rd=ssl
Chrome
Exception in thread "main" java.lang.NoClassDefFoundError: org/openqa/selenium/WrapsDriver
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:763)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:467)
at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
at java.net.URLClassLoader$1.run(URLClassLoader.java:368)
at java.net.URLClassLoader$1.run(URLClassLoader.java:362)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:361)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at org.openqa.selenium.htmlunit.HtmlUnitDriver.toWebElement(HtmlUnitDriver.java:1211)
at org.openqa.selenium.htmlunit.HtmlUnitDriver.findElementByName(HtmlUnitDriver.java:1341)
at org.openqa.selenium.By$ByName.findElement(By.java:284)
at org.openqa.selenium.htmlunit.HtmlUnitDriver$4.call(HtmlUnitDriver.java:2024)
at org.openqa.selenium.htmlunit.HtmlUnitDriver$4.call(HtmlUnitDriver.java:2020)
at org.openqa.selenium.htmlunit.HtmlUnitDriver.implicitlyWaitFor(HtmlUnitDriver.java:1660)
at org.openqa.selenium.htmlunit.HtmlUnitDriver.findElement(HtmlUnitDriver.java:2020)
at org.openqa.selenium.htmlunit.HtmlUnitDriver.findElement(HtmlUnitDriver.java:798)
at com.test.htmlUnitTest.main(htmlUnitTest.java:26)
Caused by: java.lang.ClassNotFoundException: org.openqa.selenium.WrapsDriver
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 21 more

Steps to reproduce -

maven dependencies

junit junit 3.8.1 test org.testng testng 6.9.10 org.seleniumhq.selenium selenium-java 3.12.0 org.seleniumhq.selenium htmlunit-driver org.seleniumhq.selenium htmlunit-driver 2.32.1

Java Code :

package com.test;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.Proxy;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;	
import org.openqa.selenium.htmlunit.HtmlUnitDriver;		
public class htmlUnitTest {				
		public static void main(String[] args) throws InterruptedException {
			HtmlUnitDriver  driver = new HtmlUnitDriver();
			Proxy proxy = new Proxy();
			proxy.setHttpProxy("135.28.13.11:8080"); 
			((HtmlUnitDriver) driver).setProxySettings(proxy);
                     driver.get("http://www.google.com");
                     driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
                   System.out.println(driver.getCurrentUrl());
                   System.out.println(driver.getBrowserVersion());
                    WebElement element = driver.findElement(By.name("q"));	
                    element.sendKeys("Guru99");	
                    element.submit();			
                    System.out.println("Page title is: " + driver.getTitle());		
                    driver.quit();			
         }		
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions