2016-11-08 61 views
5

我在我的Maven項目中有selenium-java 3.0.1。我讀過這個版本不包含HTMLUnitDriver。所以,我在我的pom中分別包含了selenium-htmlunit-driver 2.52.0(最新版本)。然而,當我這樣做,我得到的測試運行以下異常:Selenium 3.0.x與HTMLUnitDriver

org.openqa.selenium.WebDriverException:java.lang.IllegalArgumentException異常:無法找到已聲明字段類org.apache.http.impl.client .HttpClientBuilder.sslcontext

this鏈接,其中包括硒,Java和硒的HtmlUnit驅動的依賴應該是足夠的。在某些情況下,可能還需要包含獨立服務器,而我的項目不屬於這種情況。無論如何我都試過了,那也沒用。

selenium-htmlunit-driver 2.52.0在內部依賴於org.apache.httpcomponents 4.5.1。

selenium-java 2.47.0使用htmlunit-driver 2.47.0它使用org.apache.httpcomponents 4.4.1。當我使用這些版本時,一切正常。

所以我的問題是,HTMLUnitDriver是否可以與Selenium 3.0.x一起使用?或者我的理解在這裏完全錯誤?

回答

0

Selenium已更改工件ID。改爲使用htmlunit-driver

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

參見: https://github.com/SeleniumHQ/htmlunit-driver