Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Selenium 3.0.x with HTMLUnitDriver

I have selenium-java 3.0.1 in my Maven project. I have read that this version does not come packaged with HTMLUnitDriver. So, I have separately included selenium-htmlunit-driver 2.52.0 in my pom (the latest version available). However, when I do this, I get the following exception on test run:

org.openqa.selenium.WebDriverException: java.lang.IllegalArgumentException: Cannot locate declared field class org.apache.http.impl.client.HttpClientBuilder.sslcontext

According to this link, including the selenium-java and selenium-htmlunit-driver dependencies should be sufficient. In some scenarios, the standalone server may need to be included as well, which is not the case for my project. I tried it anyway, and that didn't work either.

selenium-htmlunit-driver 2.52.0 is internally dependent on org.apache.httpcomponents 4.5.1.

selenium-java 2.47.0 uses htmlunit-driver 2.47.0 which uses org.apache.httpcomponents 4.4.1. When I use these versions, everything works correctly.

So my question is, can HTMLUnitDriver not be used with Selenium 3.0.x at all? Or is my understanding completely wrong here?

like image 278
user1825770 Avatar asked Nov 08 '16 17:11

user1825770


People also ask

What is HtmlUnitDriver selenium?

HtmlUnitDriver is headless driver providing non-GUI implementation of Selenium WebDriver. It is based on HtmlUnit, fastest and light-weight browser implemented in Java.

Does HtmlUnitDriver API is the fastest?

HTML UnitDriver is the most light weight and fastest implementation headless browser for of WebDriver. It is based on HtmlUnit. It is known as Headless Browser Driver. It is same as Chrome, IE, or FireFox driver, but it does not have GUI so one cannot see the test execution on screen.

Can we take screenshot in HtmlUnitDriver?

htmlunit driver does not support screenshots · Issue #1361 · SeleniumHQ/selenium-google-code-issue-archive · GitHub. This repository has been archived by the owner. It is now read-only.

What is htmlunitdriver in Selenium WebDriver?

What Is HtmlUnitDriver? HtmlUnitDriver is headless browser you could launch with Selenium Web Driver, meaning that it’s a browser without a user interface. Such browsers have many advantages, like taking less resources, since they don’t have to render the web elements visually on the screen.

What is a headless Selenium WebDriver driver?

HtmlUnitDriver is headless driver providing non-GUI implementation of Selenium WebDriver. It is based on HtmlUnit, fastest and light-weight browser implemented in Java. Test execution using HtmlUnitDriver is very fast.

What is the fastest Selenium WebDriver implementation for test execution?

Test execution using HtmlUnitDriver is very fast. Since, it is the fastest implementation of Selenium WebDriver. Being headless and fast, it is an ideal choice for web scrapping. Its browser – htmlUnit is Java-based.

What is HtmlUnit driver?

HtmlUnit Driver is a well known Headless Browser driver. HtmlUnit Driver is similar to the other drivers such as Mozilla Firefox, Google Chrome, Internet Explorer but you couldn’t see the GUI of Html UnitDriver. You can create a HtmlUnitWebDriver as shown below


1 Answers

Selenium has changed artifact id. Use htmlunit-driver instead.

<dependency>
    <groupId>org.seleniumhq.selenium</groupId>
    <artifactId>htmlunit-driver</artifactId>
    <version>2.23.2</version>
</dependency>

See also: https://github.com/SeleniumHQ/htmlunit-driver

like image 196
William Bakker Avatar answered Nov 05 '22 04:11

William Bakker