Reputation: 51
I am trying to use HTMLUnitDriver in my selenium test to understand how HTMLUnitDriver works. Kindly help me with resolving the issue.
I have added the below jars to the build path in eclipse selenium-java-2.53.0 jars TestNG jar
Added the below jars as these were mentioned in other posts as a solution to the error I encountered. However, the issue remains.
selenium-htmlunit-driver-2.52.0 jar selenium-server-standalone-2.53.0
Code:
import org.openqa.selenium.htmlunit.HtmlUnitDriver;
import org.testng.annotations.Test;
public class GoogleSearch {
@Test
public void testHTMLUnitDriver() {
HtmlUnitDriver unitDriver = new HtmlUnitDriver();
unitDriver.get("https://www.google.co.uk/");
System.out.println("Title of the page is:" +unitDriver.getTitle());
}
}
Upvotes: 1
Views: 4793
Reputation: 549
You need to add htmlunit-cssparser as dependency
<dependency>
<groupId>net.sourceforge.htmlunit</groupId>
<artifactId>htmlunit-cssparser</artifactId>
<version>1.2.0</version>
<scope>test</scope>
</dependency>
Upvotes: 0
Reputation: 2148
You don't only need the HtmlUnitDriver in your classpath, you also need HtmlUnit itself in the classpath. These are not the same thing. HtmlUnitDriver is the selenium driver that can talk to the HtmlUnit headless browser. Download from here: http://htmlunit.sourceforge.net/
Upvotes: 4