seleniumhq / htmlunit-driver Goto Github PK
View Code? Open in Web Editor NEWWebDriver compatible driver for HtmlUnit headless browser.
License: Apache License 2.0
WebDriver compatible driver for HtmlUnit headless browser.
License: Apache License 2.0
as title.^^
As per issue #49 there is a severe memory leak, and while it applies to all uses of Htmlunitdriver it becomes really obvious when JavaScript is used, because of how much memory is used.
Long story short, I used VisualVM to track down what was holding the scriptable objects, and it turned out to be HtmlUnitDriver.elementsMap. Specifically the memory leak happens here.
The map is populated, but not cleared on browsing to new page. Make a HtmlUnitDriver subclass with the following override fixes the issue:
`
@Override
protected WebClient modifyWebClient( WebClient client )
{
try
{
Field field = getClass().getSuperclass().getDeclaredField( "elementsMap" );
field.setAccessible( true );
client.addWebWindowListener( new WebWindowListener()
{
@Override
public void webWindowOpened( WebWindowEvent webWindowEvent )
{
}
@Override
public void webWindowContentChanged( WebWindowEvent event )
{
try
{
Map map = (Map) field.get( ExtendedHtmlUnitDriver.this );
map.clear();
}
catch ( IllegalAccessException e )
{
e.printStackTrace();
}
}
@Override
public void webWindowClosed( WebWindowEvent event )
{
}
} );
}
catch ( NoSuchFieldException e )
{
e.printStackTrace();
}
return client;
}
`
Workaround:
Until the issue is fixed, users can create custom subclasses with the above fix to avoid the memory leak.
WebDriver choosenDriver = new HtmlUnitDriver()
<selenium.version>2.53.0</selenium.version>
<htmlunitdriver.version>2.20</htmlunitdriver.version>
Gives me exception:
Message: Bad type on operand stack Exception Details: Location:
org/openqa/selenium/htmlunit/HtmlUnitKeyboard.performSingleKeyAction(Lcom/gargoylesoftware/htmlunit/html/HtmlElement;Ljava/lang/CharSequence;Ljava/lang/String;)V @48: invokevirtual Reason: Type 'com/gargoylesoftware/htmlunit/javascript/host/event/KeyboardEvent' (current frame, stack[1]) is not assignable to 'com/gargoylesoftware/htmlunit/javascript/host/event/Event' Current Frame: bci: @48 flags: { } locals: { 'org/openqa/selenium/htmlunit/HtmlUnitKeyboard', 'com/gargoylesoftware/htmlunit/html/HtmlElement', 'java/lang/CharSequence', 'java/lang/String', integer, integer, integer, 'com/gargoylesoftware/htmlunit/javascript/host/event/KeyboardEvent' } stack: { 'com/gargoylesoftware/htmlunit/html/HtmlElement', 'com/gargoylesoftware/htmlunit/javascript/host/event/KeyboardEvent' } Bytecode: 0000000: 2cb2 0030 b600 3136 042c b200 32b6 0031 0000010: 3605 2cb2 0033 b600 3136 06bb 0034 592b 0000020: 2d03 1504 1505 1506 b700 353a 072b 1907 0000030: b600 3657 b1
In older version 2.52 I not got that issue.
Hi,
My setup works perfectly fine with URL without QueryString but as soon as i add any url with queryString, the htmlUnit Driver returns text page instead of a DOM xml. below is my Setup . can some one guide?
Script:
{
DesiredCapabilities capabilities = DesiredCapabilities.htmlUnit();
capabilities.setJavascriptEnabled(true);
WebDriver driver = new HtmlUnitDriver(capabilities);
driver.get("https://www.google.com/search?q=webdriver&gws_rd=ssl");
WebElement element = driver.findElement(By.id("lst-ib"));
element.sendKeys("Selenium");
System.out.println("Page title is: " + driver.getTitle());
driver.quit();
}
Dependancies:
<dependencies>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>htmlunit-driver</artifactId>
<version>2.20</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>2.53.0</version>
</dependency>
</dependencies>
Error:
java.lang.IllegalStateException: Unable to locate element by name for com.gargoylesoftware.htmlunit.TextPage@10ec523c
at org.openqa.selenium.htmlunit.HtmlUnitDriver.findElementByTagName(HtmlUnitDriver.java:1097)
at org.openqa.selenium.By$ByTagName.findElement(By.java:334)
at org.openqa.selenium.htmlunit.HtmlUnitDriver$5.call(HtmlUnitDriver.java:1705)
at org.openqa.selenium.htmlunit.HtmlUnitDriver$5.call(HtmlUnitDriver.java:1701)
at org.openqa.selenium.htmlunit.HtmlUnitDriver.implicitlyWaitFor(HtmlUnitDriver.java:1347)
at org.openqa.selenium.htmlunit.HtmlUnitDriver.findElement(HtmlUnitDriver.java:1701)
at org.openqa.selenium.htmlunit.HtmlUnitDriver.findElement(HtmlUnitDriver.java:586)
at com.about.venus.core.driver.WebDriverExtended.findElement(WebDriverExtended.java:213)
at com.about.venus.core.driver.WebDriverExtended.findElementEx(WebDriverExtended.java:217)
Dear all , after adding the "HtmlUnitDriver" to pom.xml and installing it ,
import org.openqa.selenium.htmlunit.HtmlUnitDriver; can not be resolved!
http://i.imgur.com/kUyePPn.png
Please advice
When accessing a website with an anchor, CSS styles for a matching :target do not apply as expected.
Minimal test site:
<!DOCTYPE html>
<html>
<head>
<style>
.tab div {
display: none;
}
.tab div:target {
display: block;
}
</style>
</head>
<body>
<div class="tab">
<a id="link" href="#anchor">Link</a>
<div id="anchor">
<p>Content</p>
</div>
</div>
</body>
</html>
Minimal Java test code:
getWebDriver().get(TEST_URL);
getWebDriver().findElement(By.id("link")).click();
System.out.println(getWebDriver().findElement(By.id("anchor")).isDisplayed());
getWebDriver().get(TEST_URL + "#anchor");
System.out.println(getWebDriver().findElement(By.id("anchor")).isDisplayed());
Result:
Both times 'false' ist printed.
When searching for an element by ID and the element could not be found on the page, HtmlUnitDriver does not throw a NoSuchElementException as expected, but returns an HtmlUnitWebElement wrapping a null DomElement.
This is because HtmlUnit's getElementById() method does not throw an exception, but returns null, if the element could not be found.
Can someone with admin rights enable htmlunit-driver
on travis-ci.org?
Thanks
@NaukhaizAhmad commented on Thu Jul 20 2017
OS:
Windows 7 64-bit
Selenium Version:
Selenium web driver 3.4.0
Browser:
HtmlUnitDriver (htmlunit-driver-2.26.jar)
Sample test script should work fine with the BrowserVersion argument.
Sample script works fine with HtmlUnitDriver but gives an error whenever a browser version is specified with the HtmlUnitDriver
package test1;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.htmlunit.HtmlUnitDriver;
import org.testng.Assert;
import org.testng.annotations.Test;
import com.gargoylesoftware.htmlunit.BrowserVersion;
public class SampleTest {
public SampleTest()
{
}
@Test
public void verify()
{
//WebDriver driver = new HtmlUnitDriver(); -- works fine in this case
WebDriver driver = new HtmlUnitDriver(BrowserVersion.FIREFOX_38);
driver.get("http://www.google.com");
System.out.println(driver.getTitle());
driver.findElement(By.name("q")).clear();
driver.findElement(By.name("q")).sendKeys("selenium");
driver.findElement(By.name("btnG")).click();
System.out.println(driver.getTitle());
String abc = driver.getTitle();
Assert.assertTrue(abc.contains("selenium"));
driver.quit();
}
The output error which i'm getting is,
[TestNG] Running:
C:\Users\naukhaiz.ahmad\AppData\Local\Temp\testng-eclipse--1506748139\testng-customsuite.xml
Google
Jul 20, 2017 6:07:39 PM com.gargoylesoftware.htmlunit.DefaultCssErrorHandler error
WARNING: CSS error: 'https://www.google.com.pk/?gws_rd=cr,ssl&ei=GatwWY2dOcyuUojqnYAG' [1:6925] Error in expression; ':' found after identifier "progid".
Jul 20, 2017 6:07:39 PM com.gargoylesoftware.htmlunit.DefaultCssErrorHandler error
WARNING: CSS error: 'https://www.google.com.pk/?gws_rd=cr,ssl&ei=GatwWY2dOcyuUojqnYAG' [1:7638] Error in expression; ':' found after identifier "progid".
Jul 20, 2017 6:07:39 PM com.gargoylesoftware.htmlunit.DefaultCssErrorHandler error
WARNING: CSS error: 'https://www.google.com.pk/?gws_rd=cr,ssl&ei=GatwWY2dOcyuUojqnYAG' [1:10007] Error in expression; ':' found after identifier "progid".
Jul 20, 2017 6:07:39 PM com.gargoylesoftware.htmlunit.DefaultCssErrorHandler error
WARNING: CSS error: 'https://www.google.com.pk/?gws_rd=cr,ssl&ei=GatwWY2dOcyuUojqnYAG' [1:10543] Error in expression; ':' found after identifier "progid".
Jul 20, 2017 6:07:39 PM com.gargoylesoftware.htmlunit.DefaultCssErrorHandler error
WARNING: CSS error: 'https://www.google.com.pk/?gws_rd=cr,ssl&ei=GatwWY2dOcyuUojqnYAG' [1:22616] Error in expression; ':' found after identifier "progid".
Jul 20, 2017 6:07:39 PM com.gargoylesoftware.htmlunit.DefaultCssErrorHandler error
WARNING: CSS error: 'https://www.google.com.pk/?gws_rd=cr,ssl&ei=GatwWY2dOcyuUojqnYAG' [1:26696] Error in expression; ':' found after identifier "progid".
Jul 20, 2017 6:07:39 PM com.gargoylesoftware.htmlunit.DefaultCssErrorHandler error
WARNING: CSS error: 'https://www.google.com.pk/?gws_rd=cr,ssl&ei=GatwWY2dOcyuUojqnYAG' [1:27142] Error in expression; ':' found after identifier "progid".
Jul 20, 2017 6:07:40 PM com.gargoylesoftware.htmlunit.DefaultCssErrorHandler error
WARNING: CSS error: 'https://www.google.com.pk/?gws_rd=cr,ssl&ei=GatwWY2dOcyuUojqnYAG' [1:923] Error in expression; ':' found after identifier "progid".
Jul 20, 2017 6:07:40 PM com.gargoylesoftware.htmlunit.DefaultCssErrorHandler error
WARNING: CSS error: 'https://www.google.com.pk/?gws_rd=cr,ssl&ei=GatwWY2dOcyuUojqnYAG' [1:1636] Error in expression; ':' found after identifier "progid".
Jul 20, 2017 6:07:40 PM com.gargoylesoftware.htmlunit.DefaultCssErrorHandler error
WARNING: CSS error: 'https://www.google.com.pk/?gws_rd=cr,ssl&ei=GatwWY2dOcyuUojqnYAG' [1:4005] Error in expression; ':' found after identifier "progid".
Jul 20, 2017 6:07:40 PM com.gargoylesoftware.htmlunit.DefaultCssErrorHandler error
WARNING: CSS error: 'https://www.google.com.pk/?gws_rd=cr,ssl&ei=GatwWY2dOcyuUojqnYAG' [1:4541] Error in expression; ':' found after identifier "progid".
Jul 20, 2017 6:07:40 PM com.gargoylesoftware.htmlunit.DefaultCssErrorHandler error
WARNING: CSS error: 'https://www.google.com.pk/?gws_rd=cr,ssl&ei=GatwWY2dOcyuUojqnYAG' [1:10036] Error in expression; ':' found after identifier "progid".
Jul 20, 2017 6:07:40 PM com.gargoylesoftware.htmlunit.DefaultCssErrorHandler error
WARNING: CSS error: 'https://www.google.com.pk/?gws_rd=cr,ssl&ei=GatwWY2dOcyuUojqnYAG' [1:10528] Error in expression; ':' found after identifier "progid".
Jul 20, 2017 6:07:40 PM com.gargoylesoftware.htmlunit.DefaultCssErrorHandler error
WARNING: CSS error: 'https://www.google.com.pk/?gws_rd=cr,ssl&ei=GatwWY2dOcyuUojqnYAG' [1:13846] Error in expression. (Invalid token " ". Was expecting one of: , "inherit", , , , , , <LENGTH_PX>, <LENGTH_CM>, <LENGTH_MM>, <LENGTH_IN>, <LENGTH_PT>, <LENGTH_PC>, <ANGLE_DEG>, <ANGLE_RAD>, <ANGLE_GRAD>, <TIME_MS>, <TIME_S>, <FREQ_HZ>, <FREQ_KHZ>, <RESOLUTION_DPI>, <RESOLUTION_DPCM>, , , , .)
Jul 20, 2017 6:07:40 PM com.gargoylesoftware.htmlunit.DefaultCssErrorHandler error
WARNING: CSS error: 'https://www.google.com.pk/?gws_rd=cr,ssl&ei=GatwWY2dOcyuUojqnYAG' [1:13870] Error in expression. (Invalid token " ". Was expecting one of: , "inherit", , , , , , <LENGTH_PX>, <LENGTH_CM>, <LENGTH_MM>, <LENGTH_IN>, <LENGTH_PT>, <LENGTH_PC>, <ANGLE_DEG>, <ANGLE_RAD>, <ANGLE_GRAD>, <TIME_MS>, <TIME_S>, <FREQ_HZ>, <FREQ_KHZ>, <RESOLUTION_DPI>, <RESOLUTION_DPCM>, , , , .)
FAILED: verify
org.openqa.selenium.ElementNotVisibleException: You may only interact with visible elements
Build info: version: '2.46.0', revision: '87c69e2', time: '2015-06-04 16:16:47'
System info: host: 'SS01-NBK-035', ip: '10.1.18.37', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_51'
Driver info: driver.version: unknown
at org.openqa.selenium.htmlunit.HtmlUnitWebElement.verifyCanInteractWithElement(HtmlUnitWebElement.java:280)
at org.openqa.selenium.htmlunit.HtmlUnitWebElement.click(HtmlUnitWebElement.java:138)
at test1.phantomTest.verify(phantomTest.java:68)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:84)
at org.testng.internal.Invoker.invokeMethod(Invoker.java:714)
at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:901)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1231)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:127)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:111)
at org.testng.TestRunner.privateRun(TestRunner.java:767)
at org.testng.TestRunner.run(TestRunner.java:617)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:334)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:329)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:291)
at org.testng.SuiteRunner.run(SuiteRunner.java:240)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1224)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1149)
at org.testng.TestNG.run(TestNG.java:1057)
at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:132)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:230)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:76)
[TestNG] Time taken by org.testng.reporters.XMLReporter@28864e92: 16 ms
[TestNG] Time taken by org.testng.reporters.EmailableReporter2@1888ff2c: 7 ms
[TestNG] Time taken by org.testng.reporters.jq.Main@7cdbc5d3: 42 ms
[TestNG] Time taken by org.testng.reporters.SuiteHTMLReporter@33a10788: 46 ms
[TestNG] Time taken by org.testng.reporters.JUnitReportReporter@357246de: 6 ms
[TestNG] Time taken by [FailedReporter passed=0 failed=0 skipped=0]: 8 ms
Please suggest a solution or a way around.
Exception in thread "main" org.openqa.selenium.WebDriverException: java.lang.IllegalArgumentException: Cannot locate declared field class org.apache.http.impl.client.HttpClientBuilder.dnsResolver
when attempting to run the following code:
Im getting the following error back:
"C:\Program Files\Java\jdk1.8.0_131\bin\java" -ea -Didea.test.cyclic.buffer.size=1048576 "-javaagent:C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2017.2.3\lib\idea_rt.jar=63496:C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2017.2.3\bin" -Dfile.encoding=UTF-8 -classpath "C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2017.2.3\lib\idea_rt.jar;C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2017.2.3\plugins\junit\lib\junit-rt.jar;C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2017.2.3\plugins\junit\lib\junit5-rt.jar;C:\Program Files\Java\jdk1.8.0_131\jre\lib\charsets.jar;C:\Program Files\Java\jdk1.8.0_131\jre\lib\deploy.jar;C:\Program Files\Java\jdk1.8.0_131\jre\lib\ext\access-bridge-64.jar;C:\Program Files\Java\jdk1.8.0_131\jre\lib\ext\cldrdata.jar;C:\Program Files\Java\jdk1.8.0_131\jre\lib\ext\dnsns.jar;C:\Program Files\Java\jdk1.8.0_131\jre\lib\ext\jaccess.jar;C:\Program Files\Java\jdk1.8.0_131\jre\lib\ext\jfxrt.jar;C:\Program Files\Java\jdk1.8.0_131\jre\lib\ext\localedata.jar;C:\Program Files\Java\jdk1.8.0_131\jre\lib\ext\nashorn.jar;C:\Program Files\Java\jdk1.8.0_131\jre\lib\ext\sunec.jar;C:\Program Files\Java\jdk1.8.0_131\jre\lib\ext\sunjce_provider.jar;C:\Program Files\Java\jdk1.8.0_131\jre\lib\ext\sunmscapi.jar;C:\Program Files\Java\jdk1.8.0_131\jre\lib\ext\sunpkcs11.jar;C:\Program Files\Java\jdk1.8.0_131\jre\lib\ext\zipfs.jar;C:\Program Files\Java\jdk1.8.0_131\jre\lib\javaws.jar;C:\Program Files\Java\jdk1.8.0_131\jre\lib\jce.jar;C:\Program Files\Java\jdk1.8.0_131\jre\lib\jfr.jar;C:\Program Files\Java\jdk1.8.0_131\jre\lib\jfxswt.jar;C:\Program Files\Java\jdk1.8.0_131\jre\lib\jsse.jar;C:\Program Files\Java\jdk1.8.0_131\jre\lib\management-agent.jar;C:\Program Files\Java\jdk1.8.0_131\jre\lib\plugin.jar;C:\Program Files\Java\jdk1.8.0_131\jre\lib\resources.jar;C:\Program Files\Java\jdk1.8.0_131\jre\lib\rt.jar;C:\Users\ra.r.hope\IdeaProjects\webdriverbasics\target\test-classes;C:\Users\robert.hope\.m2\repository\org\seleniumhq\selenium\htmlunit-driver\2.27\htmlunit-driver-2.27.jar;C:\Users\robert.hope\.m2\repository\org\seleniumhq\selenium\selenium-api\3.4.0\selenium-api-3.4.0.jar;C:\Users\robert.hope\.m2\repository\net\sourceforge\htmlunit\htmlunit\2.27\htmlunit-2.27.jar;C:\Users\robert.hope\.m2\repository\junit\junit\4.12\junit-4.12.jar;C:\Users\robert.hope\.m2\repository\org\hamcrest\hamcrest-core\1.3\hamcrest-core-1.3.jar;C:\Users\robert.hope\.m2\repository\org\seleniumhq\selenium\selenium-java\3.5.3\selenium-java-3.5.3.jar;C:\Users\robert.hope\.m2\repository\org\seleniumhq\selenium\selenium-chrome-driver\3.5.3\selenium-chrome-driver-3.5.3.jar;C:\Users\robert.hope\.m2\repository\org\seleniumhq\selenium\selenium-edge-driver\3.5.3\selenium-edge-driver-3.5.3.jar;C:\Users\robert.hope\.m2\repository\org\seleniumhq\selenium\selenium-firefox-driver\3.5.3\selenium-firefox-driver-3.5.3.jar;C:\Users\robert.hope\.m2\repository\org\seleniumhq\selenium\selenium-ie-driver\3.5.3\selenium-ie-driver-3.5.3.jar;C:\Users\robert.hope\.m2\repository\org\seleniumhq\selenium\selenium-opera-driver\3.5.3\selenium-opera-driver-3.5.3.jar;C:\Users\robert.hope\.m2\repository\org\seleniumhq\selenium\selenium-remote-driver\3.5.3\selenium-remote-driver-3.5.3.jar;C:\Users\robert.hope\.m2\repository\org\seleniumhq\selenium\selenium-safari-driver\3.5.3\selenium-safari-driver-3.5.3.jar;C:\Users\robert.hope\.m2\repository\cglib\cglib-nodep\3.2.4\cglib-nodep-3.2.4.jar;C:\Users\robert.hope\.m2\repository\org\apache\commons\commons-exec\1.3\commons-exec-1.3.jar;C:\Users\robert.hope\.m2\repository\org\apache\commons\commons-lang3\3.5\commons-lang3-3.5.jar;C:\Users\robert.hope\.m2\repository\commons-codec\commons-codec\1.10\commons-codec-1.10.jar;C:\Users\robert.hope\.m2\repository\commons-io\commons-io\2.5\commons-io-2.5.jar;C:\Users\robert.hope\.m2\repository\commons-logging\commons-logging\1.2\commons-logging-1.2.jar;C:\Users\robert.hope\.m2\repository\org\w3c\css\sac\1.3\sac-1.3.jar;C:\Users\robert.hope\.m2\repository\net\sourceforge\cssparser\cssparser\0.9.23\cssparser-0.9.23.jar;C:\Users\robert.hope\.m2\repository\com\google\code\gson\gson\2.8.0\gson-2.8.0.jar;C:\Users\robert.hope\.m2\repository\com\google\guava\guava\23.0\guava-23.0.jar;C:\Users\robert.hope\.m2\repository\com\google\code\findbugs\jsr305\1.3.9\jsr305-1.3.9.jar;C:\Users\robert.hope\.m2\repository\com\google\errorprone\error_prone_annotations\2.0.18\error_prone_annotations-2.0.18.jar;C:\Users\robert.hope\.m2\repository\com\google\j2objc\j2objc-annotations\1.1\j2objc-annotations-1.1.jar;C:\Users\robert.hope\.m2\repository\org\codehaus\mojo\animal-sniffer-annotations\1.14\animal-sniffer-annotations-1.14.jar;C:\Users\robert.hope\.m2\repository\net\sourceforge\htmlunit\htmlunit-core-js\2.27\htmlunit-core-js-2.27.jar;C:\Users\robert.hope\.m2\repository\net\sourceforge\htmlunit\neko-htmlunit\2.27\neko-htmlunit-2.27.jar;C:\Users\robert.hope\.m2\repository\org\apache\httpcomponents\httpclient\4.5.3\httpclient-4.5.3.jar;C:\Users\robert.hope\.m2\repository\org\apache\httpcomponents\httpcore\4.4.6\httpcore-4.4.6.jar;C:\Users\robert.hope\.m2\repository\org\apache\httpcomponents\httpmime\4.5.3\httpmime-4.5.3.jar;C:\Users\robert.hope\.m2\repository\org\eclipse\jetty\jetty-client\9.4.5.v20170502\jetty-client-9.4.5.v20170502.jar;C:\Users\robert.hope\.m2\repository\org\eclipse\jetty\jetty-http\9.4.5.v20170502\jetty-http-9.4.5.v20170502.jar;C:\Users\robert.hope\.m2\repository\org\eclipse\jetty\jetty-io\9.4.5.v20170502\jetty-io-9.4.5.v20170502.jar;C:\Users\robert.hope\.m2\repository\org\eclipse\jetty\jetty-util\9.4.5.v20170502\jetty-util-9.4.5.v20170502.jar;C:\Users\robert.hope\.m2\repository\net\java\dev\jna\jna\4.1.0\jna-4.1.0.jar;C:\Users\robert.hope\.m2\repository\net\java\dev\jna\jna-platform\4.1.0\jna-platform-4.1.0.jar;C:\Users\robert.hope\.m2\repository\com\codeborne\phantomjsdriver\1.4.0\phantomjsdriver-1.4.0.jar;C:\Users\robert.hope\.m2\repository\javax\servlet\javax.servlet-api\3.1.0\javax.servlet-api-3.1.0.jar;C:\Users\robert.hope\.m2\repository\org\eclipse\jetty\websocket\websocket-api\9.4.5.v20170502\websocket-api-9.4.5.v20170502.jar;C:\Users\robert.hope\.m2\repository\org\eclipse\jetty\websocket\websocket-client\9.4.5.v20170502\websocket-client-9.4.5.v20170502.jar;C:\Users\robert.hope\.m2\repository\org\eclipse\jetty\websocket\websocket-common\9.4.5.v20170502\websocket-common-9.4.5.v20170502.jar;C:\Users\robert.hope\.m2\repository\xalan\serializer\2.7.2\serializer-2.7.2.jar;C:\Users\robert.hope\.m2\repository\xalan\xalan\2.7.2\xalan-2.7.2.jar;C:\Users\robert.hope\.m2\repository\xerces\xercesImpl\2.11.0\xercesImpl-2.11.0.jar;C:\Users\robert.hope\.m2\repository\xml-apis\xml-apis\1.4.01\xml-apis-1.4.01.jar" com.intellij.rt.execution.junit.JUnitStarter -ideVersion5 -junit4 com.seleniumsimplified.webdriver.FirstTest
Oct 06, 2017 9:50:29 AM org.apache.http.impl.execchain.RetryExec execute
INFO: I/O exception (java.net.SocketException) caught when processing request to {s}->https://www.compendiumdev.co.uk:443: Connection reset
Oct 06, 2017 9:50:29 AM org.apache.http.impl.execchain.RetryExec execute
INFO: Retrying request to {s}->https://www.compendiumdev.co.uk:443
Oct 06, 2017 9:51:29 AM org.apache.http.impl.execchain.RetryExec execute
INFO: I/O exception (java.net.SocketException) caught when processing request to {s}->https://www.compendiumdev.co.uk:443: Connection reset
Oct 06, 2017 9:51:29 AM org.apache.http.impl.execchain.RetryExec execute
INFO: Retrying request to {s}->https://www.compendiumdev.co.uk:443
Oct 06, 2017 9:52:29 AM org.apache.http.impl.execchain.RetryExec execute
INFO: I/O exception (java.net.SocketException) caught when processing request to {s}->https://www.compendiumdev.co.uk:443: Connection reset
Oct 06, 2017 9:52:29 AM org.apache.http.impl.execchain.RetryExec execute
INFO: Retrying request to {s}->https://www.compendiumdev.co.uk:443
org.openqa.selenium.WebDriverException: java.net.SocketException: Connection reset
Build info: version: '3.4.0', revision: 'unknown', time: 'unknown'
System info: host: 'LT-LGC07999', ip: '10.44.22.11', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_131'
Driver info: driver.version: HtmlUnitDriver
at org.openqa.selenium.htmlunit.HtmlUnitDriver.get(HtmlUnitDriver.java:686)
at org.openqa.selenium.htmlunit.HtmlUnitDriver.lambda$8(HtmlUnitDriver.java:655)
at org.openqa.selenium.htmlunit.HtmlUnitDriver.lambda$0(HtmlUnitDriver.java:412)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.net.SocketException: Connection reset
at java.net.SocketInputStream.read(SocketInputStream.java:210)
at java.net.SocketInputStream.read(SocketInputStream.java:141)
at sun.security.ssl.InputRecord.readFully(InputRecord.java:465)
at sun.security.ssl.InputRecord.read(InputRecord.java:503)
at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:973)
at sun.security.ssl.SSLSocketImpl.waitForClose(SSLSocketImpl.java:1769)
at sun.security.ssl.HandshakeOutStream.flush(HandshakeOutStream.java:124)
at sun.security.ssl.Handshaker.kickstart(Handshaker.java:1067)
at sun.security.ssl.SSLSocketImpl.kickstartHandshake(SSLSocketImpl.java:1487)
at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1351)
at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1403)
at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1387)
at org.apache.http.conn.ssl.SSLConnectionSocketFactory.createLayeredSocket(SSLConnectionSocketFactory.java:396)
at org.apache.http.conn.ssl.SSLConnectionSocketFactory.connectSocket(SSLConnectionSocketFactory.java:355)
at com.gargoylesoftware.htmlunit.httpclient.HtmlUnitSSLConnectionSocketFactory.connectSocket(HtmlUnitSSLConnectionSocketFactory.java:186)
at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:142)
at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.connect(PoolingHttpClientConnectionManager.java:359)
at org.apache.http.impl.execchain.MainClientExec.establishRoute(MainClientExec.java:381)
at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:237)
at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:185)
at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:89)
at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:111)
at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:185)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:72)
at com.gargoylesoftware.htmlunit.HttpWebConnection.getResponse(HttpWebConnection.java:194)
at com.gargoylesoftware.htmlunit.WebClient.loadWebResponseFromWebConnection(WebClient.java:1379)
at com.gargoylesoftware.htmlunit.WebClient.loadWebResponseFromWebConnection(WebClient.java:1429)
at com.gargoylesoftware.htmlunit.WebClient.loadWebResponse(WebClient.java:1298)
at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:392)
at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:313)
at org.openqa.selenium.htmlunit.HtmlUnitDriver.get(HtmlUnitDriver.java:668)
... 3 more
``
Tested using Java 8
Selenium 3.5.3
HtmlUnitDriver 2.27
Windows 7
I am getting this error as soon as i do: driver = new HtmlUnitDriver();
The problem happens on armV7l
2017-11-16 15:44:06.213 ERROR 31324 --- [nio-8080-exec-1] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Handler dispatch fa iled; nested exception is java.lang.NoClassDefFoundError: org/openqa/selenium/ElementNotInteractableException] with root cause java.lang.ClassNotFoundException: org.openqa.selenium.ElementNotInteractableException at java.net.URLClassLoader.findClass(URLClassLoader.java:381) ~[na:1.8.0_151] at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[na:1.8.0_151] at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[na:1.8.0_151] at org.openqa.selenium.htmlunit.HtmlUnitDriver.resetKeyboardAndMouseState(HtmlUnitDriver.java:698) ~[htmlunit-driver-2.28.jar:na] at org.openqa.selenium.htmlunit.HtmlUnitDriver.get(HtmlUnitDriver.java:693) ~[htmlunit-driver-2.28.jar:na] at org.openqa.selenium.htmlunit.HtmlUnitDriver.get(HtmlUnitDriver.java:646) ~[htmlunit-driver-2.28.jar:na] at org.openqa.selenium.htmlunit.HtmlUnitDriver.(HtmlUnitDriver.java:256) ~[htmlunit-driver-2.28.jar:na] at org.openqa.selenium.htmlunit.HtmlUnitDriver.(HtmlUnitDriver.java:208) ~[htmlunit-driver-2.28.jar:na] at org.openqa.selenium.htmlunit.HtmlUnitDriver.(HtmlUnitDriver.java:198) ~[htmlunit-driver-2.28.jar:na] at org.openqa.selenium.htmlunit.HtmlUnitDriver.(HtmlUnitDriver.java:188) ~[htmlunit-driver-2.28.jar:na]
<dependency> <groupId>org.seleniumhq.selenium</groupId> <artifactId>selenium-java</artifactId> <version>3.7.1</version> </dependency> <dependency> <groupId>net.sourceforge.htmlunit</groupId> <artifactId>htmlunit</artifactId> <version>2.28</version> </dependency> <dependency> <groupId>org.seleniumhq.selenium</groupId> <artifactId>htmlunit-driver</artifactId> <version>2.28</version> </dependency>
I logged an issue here: SeleniumHQ/selenium#1373 but since HtmlUnitDriver has moved to the new repository, I was advised to re-log the issue. It has been verified by 2 others. Copied below for convenience:
The new alert handling functionality in HtmlUnitDriver (driver.switchTo().alert()) only handles alert boxes, not other modal dialogs such as confirm and prompt. Other drivers handle confirm, alert and prompt. The test case below illustrates this.
I know that I can install a confirmHandler for the HtmlUnit WebClient, but that requires modifying the underlying driver and messages are difficult to retrieve.
import org.junit.Test;
import org.openqa.selenium.*;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.htmlunit.HtmlUnitDriver;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.junit.Assert.assertThat;
/**
* Handling of javascript popups is implemented inconsistently for HtmlUnitDriver, since v2.47.0
*
* @author barry
* @since 2015/12/13
*/
public class AlertTest {
@Test
public void testAlerts() throws Exception {
testAlertsWithDriver(new ChromeDriver());
testAlertsWithDriver(new FirefoxDriver());
testAlertsWithDriver(new HtmlUnitDriver(true)); // test fails for HtmlUnitDriver
}
private void testAlertsWithDriver(WebDriver driver) {
driver.get("https://www.google.com");
JavascriptExecutor executor = (JavascriptExecutor) driver;
// alerts are implemented
String alertMessage = "error!";
executor.executeScript("alert('" + alertMessage + "')");
assertThat(driver.switchTo().alert().getText(), equalTo(alertMessage));
driver.switchTo().alert().accept(); // dismiss the alert
// but confirm messages aren't
String confirmMessage = "are you sure?";
executor.executeScript("confirm('" + confirmMessage + "')");
// "NoAlertPresentException: No alert was present" thrown for HtmlUnitDriver only
assertThat(driver.switchTo().alert().getText(), equalTo(confirmMessage));
driver.switchTo().alert().accept(); // dismiss the confirm
driver.quit();
}
}
Sorry if this is the wrong place to ask, but I don't know ehere else to. In different POMs I see dependencies like
Different artifact names and different versions leave me in doubt which one is the more "official" and the better maintained version. Sorry for being confused. Furthermore, most official Selenium Maven artifacts have been updated synchronously to 3.0.1, so both 2.52.0 and 2.23.1 seem a bit odd.
Hey guys,
Trying to use HtmlUnit Driver with Selenium 3.3.1, but unable to start the server.
Couldn't find much info out there, but here's what I was able to gather:
java -cp "selenium-server-standalone-3.3.1.jar:htmlunit-driver-2.25-with-dependencies.jar" org.openqa.grid.selenium.GridLauncherV3
Error: Could not find or load main class org.openqa.grid.selenium.GridLauncherV3
However, the following works:
java -cp "selenium-server-standalone-3.3.1.jar" org.openqa.grid.selenium.GridLauncherV3
Also been trying to find up to date documentation on using htmlunit driver with c#, any ideas?
Thanks.
In HtmlUnitAlert.close(), the code tries to remove an entry from the queues map with a Window object as the key, but the map actually uses Page object as keys.
I'm upgrading from 2.21 to 2.23, but invoking getAttribute("value")
on a HtmlFileInput element doesn't return the file path value anymore.
Any clue ? I also switched from Selenium 2.53.1 to 3.0.0-beta4.
Hi all,
Please note we are now ready to release htmlunit-driver
2.24. I looked into all relevant failing tests, and they are fixed either in HtmlUnit trunk
or in the driver.
Please also update the latest release in releases.
As a side note, I guess we should have HtmlUnitDriver mentioned in Selenium download page.
Thanks,
It's wired that when i try to use htmluniter driver to click element. My code is below:
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.htmlunit.HtmlUnitDriver;
public class HtmlUnitDriverTest {
@Test()
public void testUnitDriver() throws InterruptedException {
WebDriver driver = new HtmlUnitDriver();
driver.navigate().to("http://x.x.x.x/#/home");
driver.findElement(By.cssSelector("header.header--desktop.hidden-xs-down > div > div > div > a")).click();
}
}
And i got below errors:
org.openqa.selenium.NoSuchElementException: Returned node was not a DOM element
For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html
Build info: version: '2.52.0', revision: '4c2593cfc3689a7fcd7be52549167e5ccc93ad28', time: '2016-02-11 11:22:43'
System info: host: 'William-MacBook-Pro.local', ip: 'x.x.x.117', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.12.2', java.version: '1.8.0_111'
Driver info: driver.version: HtmlUnitDriver
at org.openqa.selenium.htmlunit.HtmlUnitDriver.findElementByCssSelector(HtmlUnitDriver.java:1060)
at org.openqa.selenium.By$ByCssSelector.findElement(By.java:430)
at org.openqa.selenium.htmlunit.HtmlUnitDriver$5.call(HtmlUnitDriver.java:1725)
at org.openqa.selenium.htmlunit.HtmlUnitDriver$5.call(HtmlUnitDriver.java:1721)
at org.openqa.selenium.htmlunit.HtmlUnitDriver.implicitlyWaitFor(HtmlUnitDriver.java:1367)
at org.openqa.selenium.htmlunit.HtmlUnitDriver.findElement(HtmlUnitDriver.java:1721)
at org.openqa.selenium.htmlunit.HtmlUnitDriver.findElement(HtmlUnitDriver.java:606)
at HtmlUnitDriver.test.HtmlUnitDriverTest.testUnitDriver(HtmlUnitDriverTest.java:14)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:678)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
Operations that internally call ensureAlertUnlocked()
method (e.g. getTitle()
) will get a NullPointerException
when there's an alert present on the page and the HtmlUnitDriver constructor used was not the one that takes a Capabilities
object in. It seems like this is the only constructor that sets a default value for the unexpectedAlertBehaviour
field.
Below are a few test cases (based on the existing AlertsTest
class) that reproduce the issue. The first two fail and the last one passes, since it creates the driver by using the constructor that takes the Capabilities
object.
// FAILS
@Test(expected = UnhandledAlertException.class)
public void booleanConstructor() {
HtmlUnitDriver driver = new HtmlUnitDriver(true);
driver.get(alertPage("cheese"));
driver.findElement(By.id("alert")).click();
assertEquals("Testing Alerts", driver.getTitle());
}
// FAILS
@Test(expected = UnhandledAlertException.class)
public void browserVersionAndBooleanConstructor() {
HtmlUnitDriver driver = new HtmlUnitDriver(BrowserVersion.BEST_SUPPORTED, true);
driver.get(alertPage("cheese"));
driver.findElement(By.id("alert")).click();
assertEquals("Testing Alerts", driver.getTitle());
}
// PASSES
@Test(expected = UnhandledAlertException.class)
public void capabilitiesConstructor() {
HtmlUnitDriver driver = new HtmlUnitDriver(new DesiredCapabilities(BrowserType.HTMLUNIT, null, Platform.ANY));
driver.get(alertPage("cheese"));
driver.findElement(By.id("alert")).click();
assertEquals("Testing Alerts", driver.getTitle());
}
My code is very simple:
public class HtmlUnitDriverTest {
public static void main(String[] args) {
final WebClient webClient = new WebClient();
}
}
When use htmlunit-driver 2.20, it's ok.
But when i update to 2.23, i meet the following error:
Exception in thread "main" java.lang.NoClassDefFoundError: org/eclipse/jetty/websocket/api/Session
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2625)
at java.lang.Class.getDeclaredMethods(Class.java:1868)
at com.gargoylesoftware.htmlunit.javascript.configuration.AbstractJavaScriptConfiguration.process(AbstractJavaScriptConfiguration.java:197)
at com.gargoylesoftware.htmlunit.javascript.configuration.AbstractJavaScriptConfiguration.getClassConfiguration(AbstractJavaScriptConfiguration.java:172)
at com.gargoylesoftware.htmlunit.javascript.configuration.AbstractJavaScriptConfiguration.buildUsageMap(AbstractJavaScriptConfiguration.java:79)
at com.gargoylesoftware.htmlunit.javascript.configuration.AbstractJavaScriptConfiguration.(AbstractJavaScriptConfiguration.java:59)
at com.gargoylesoftware.htmlunit.javascript.configuration.JavaScriptConfiguration.(JavaScriptConfiguration.java:597)
at com.gargoylesoftware.htmlunit.javascript.configuration.JavaScriptConfiguration.getInstance(JavaScriptConfiguration.java:613)
at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.(JavaScriptEngine.java:133)
at com.gargoylesoftware.htmlunit.WebClient.init(WebClient.java:239)
at com.gargoylesoftware.htmlunit.WebClient.(WebClient.java:213)
at com.gargoylesoftware.htmlunit.WebClient.(WebClient.java:204)
at HtmlUnitDriverTest.main(HtmlUnitDriverTest.java:11)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144)
Caused by: java.lang.ClassNotFoundException: org.eclipse.jetty.websocket.api.Session
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
... 19 more
I compare my pom.xml file of 2.20 and 2.23,
my 2.20 pom:
<dependency>
<groupId>net.sourceforge.htmlunit</groupId>
<artifactId>htmlunit</artifactId>
<version>2.20</version>
</dependency>
the 2.23 pom:
<dependency>
<groupId>net.sourceforge.htmlunit</groupId>
<artifactId>htmlunit</artifactId>
<version>2.23</version>
<exclusions>
<exclusion>
<groupId>org.eclipse.jetty.websocket</groupId>
<artifactId>websocket-client</artifactId>
</exclusion>
</exclusions>
</dependency>
Do I need to manually add the dependency for jetty?
Please help me, thanks a lot.
Inspired by: SeleniumHQ/selenium#3906
Let's suppose a user has a dependecy on selenium-java 3.3.0 (that depends on htmlunit-driver 2.24), here is what he can have in classpath:
[INFO] xxx:yyy:pom:SNAPSHOT
[INFO] \- org.seleniumhq.selenium:selenium-java:jar:3.3.0:compile
[INFO] +- org.seleniumhq.selenium:selenium-chrome-driver:jar:3.3.0:compile
[INFO] | \- org.seleniumhq.selenium:selenium-remote-driver:jar:3.3.0:compile
[INFO] | +- org.seleniumhq.selenium:selenium-api:jar:3.3.0:compile
[INFO] | +- cglib:cglib-nodep:jar:3.2.4:compile
[INFO] | +- org.apache.commons:commons-exec:jar:1.3:compile
[INFO] | +- com.google.code.gson:gson:jar:2.8.0:compile
[INFO] | +- com.google.guava:guava:jar:21.0:compile
[INFO] | +- org.apache.httpcomponents:httpclient:jar:4.5.2:compile
[INFO] | \- net.java.dev.jna:jna-platform:jar:4.1.0:compile
[INFO] +- org.seleniumhq.selenium:selenium-edge-driver:jar:3.3.0:compile
[INFO] +- org.seleniumhq.selenium:selenium-firefox-driver:jar:3.3.0:compile
[INFO] +- org.seleniumhq.selenium:selenium-ie-driver:jar:3.3.0:compile
[INFO] +- org.seleniumhq.selenium:selenium-opera-driver:jar:3.3.0:compile
[INFO] +- org.seleniumhq.selenium:selenium-safari-driver:jar:3.3.0:compile
[INFO] +- com.codeborne:phantomjsdriver:jar:1.4.0:compile
[INFO] \- org.seleniumhq.selenium:htmlunit-driver:jar:2.24:compile
[INFO] +- org.seleniumhq.selenium:selenium-support:jar:3.4.0:compile (vers
ion selected from constraint [2.53.0,4.0.0))
[INFO] | +- commons-codec:commons-codec:jar:1.10:compile
[INFO] | +- commons-logging:commons-logging:jar:1.2:compile
[INFO] | +- org.hamcrest:hamcrest-core:jar:1.3:compile
[INFO] | +- org.apache.httpcomponents:httpcore:jar:4.4.6:compile
[INFO] | +- net.java.dev.jna:jna:jar:4.1.0:compile
[INFO] | \- junit:junit:jar:4.12:compile
[INFO] \- net.sourceforge.htmlunit:htmlunit:jar:2.24:compile
[INFO] +- xalan:xalan:jar:2.7.2:compile
[INFO] | \- xalan:serializer:jar:2.7.2:compile
[INFO] +- org.apache.commons:commons-lang3:jar:3.5:compile
[INFO] +- org.apache.httpcomponents:httpmime:jar:4.5.2:compile
[INFO] +- net.sourceforge.htmlunit:htmlunit-core-js:jar:2.23:compile
[INFO] +- net.sourceforge.htmlunit:neko-htmlunit:jar:2.24:compile
[INFO] | \- xerces:xercesImpl:jar:2.11.0:compile
[INFO] | \- xml-apis:xml-apis:jar:1.4.01:compile
[INFO] +- net.sourceforge.cssparser:cssparser:jar:0.9.21:compile
[INFO] | \- org.w3c.css:sac:jar:1.3:compile
[INFO] +- commons-io:commons-io:jar:2.5:compile
[INFO] \- org.eclipse.jetty.websocket:websocket-client:jar:9.2.20.v2016
1216:compile
[INFO] +- org.eclipse.jetty:jetty-util:jar:9.2.20.v20161216:compile
[INFO] +- org.eclipse.jetty:jetty-io:jar:9.2.20.v20161216:compile
[INFO] \- org.eclipse.jetty.websocket:websocket-common:jar:9.2.20.v2
0161216:compile
[INFO] \- org.eclipse.jetty.websocket:websocket-api:jar:9.2.20.v2
0161216:compile
Note
org.seleniumhq.selenium:selenium-support:jar:3.4.0:compile (version selected from constraint [2.53.0,4.0.0))
Other dependency configurations can bring too new versions of other artifacts, up to selenium-api.
I suppose that if we change dependency on selenium-api and selenium-support to 'provided' it should eliminate this issue in the forthcoming versions of htmlunit-driver.
This works locally, but fails on my Jenkins server. From my knowlenge no additional flags are being set. I have begun debugging useing: -Djavax.net.debug=ssl,handshake
org.openqa.selenium.WebDriverException: javax.net.ssl.SSLHandshakeException: Remote host closed connection during handshake
Build info: version: '2.53.0', revision: '35ae25b1534ae328c771e0856c93e187490ca824', time: '2016-03-15 10:43:46'
System info: host: 'lp00-jen-s05', ip: '10.10.9.233', os.name: 'Linux', os.arch: 'amd64', os.version: '2.6.18-409.el5', java.version: '1.7.0_99'
Driver info: driver.version: HtmlUnitDriver
at org.openqa.selenium.htmlunit.HtmlUnitDriver.get(HtmlUnitDriver.java:534)
at org.openqa.selenium.htmlunit.HtmlUnitDriver.get(HtmlUnitDriver.java:508)
at RedirectTest.testRedirectFromTo(RedirectTest.java:65)
at RedirectTest.testPromoInUrlWithTrailingSlash(RedirectTest.java:40)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:252)
at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:141)
at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:112)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189)
at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165)
at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85)
at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:115)
at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:75)
Caused by: javax.net.ssl.SSLHandshakeException: Remote host closed connection during handshake
at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:965)
at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1344)
at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1371)
at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1355)
at org.apache.http.conn.ssl.SSLConnectionSocketFactory.createLayeredSocket(SSLConnectionSocketFactory.java:394)
at org.apache.http.conn.ssl.SSLConnectionSocketFactory.connectSocket(SSLConnectionSocketFactory.java:353)
at com.gargoylesoftware.htmlunit.httpclient.HtmlUnitSSLConnectionSocketFactory.connectSocket(HtmlUnitSSLConnectionSocketFactory.java:188)
at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:141)
at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.connect(PoolingHttpClientConnectionManager.java:353)
at org.apache.http.impl.execchain.MainClientExec.establishRoute(MainClientExec.java:380)
at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:236)
at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:184)
at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:88)
at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:110)
at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:184)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:71)
at com.gargoylesoftware.htmlunit.HttpWebConnection.getResponse(HttpWebConnection.java:177)
at com.gargoylesoftware.htmlunit.WebClient.loadWebResponseFromWebConnection(WebClient.java:1323)
at com.gargoylesoftware.htmlunit.WebClient.loadWebResponseFromWebConnection(WebClient.java:1373)
at com.gargoylesoftware.htmlunit.WebClient.loadWebResponseFromWebConnection(WebClient.java:1373)
at com.gargoylesoftware.htmlunit.WebClient.loadWebResponse(WebClient.java:1240)
at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:347)
at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:416)
at org.openqa.selenium.htmlunit.HtmlUnitDriver.get(HtmlUnitDriver.java:519)
... 33 more
Caused by: java.io.EOFException: SSL peer shut down incorrectly
at sun.security.ssl.InputRecord.read(InputRecord.java:482)
at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:946)
... 56 more
The method ensureAlertUnlocked is always throwing an UnhandledAlertException even though the alert has been accepted/dismissed.
Since the ignore-case is doing nothing, I assume that the Exception should be part of this case and the curly is just at the wrong place.
This hit us in one of our legacy-applications which we are now safeguarding with tests (we set "unexpectedAlertBehaviour" to "accept"). The tests passed in all drivers except HtmlUnit. I've tested a local build where the exception is only thrown in the IGNORE-case and now everthing is fine.
OS:
Windows 10
Selenium Version:
2.53.0
HtmlunitDriver should throw TimeOut exception when using driver.manage().timout().setPageLoadTimeOut()
Application will hang on all time
This method i tried to use API pageloadtimeout but it not working:
HtmlUnitDriver driver = new HtmlUnitDriver();
driver.manage().timeouts().pageLoadTimeout(10,TimeUnit.SECONDS);
driver.get(" http://us.24h.com.vn/");
I change to override directly to WebClient in com.gargoylesoftware.htmlunit.WebClient in code below but it still not working:
HtmlUnitDriver driver = new HtmlUnitDriver() {
@Override
protected WebClient getWebClient() {
WebClient webClient = super.getWebClient();
webClient.getCache().setMaxSize(0);
webClient.getOptions().setUseInsecureSSL(true); //ignore ssl certificate
webClient.getOptions().setThrowExceptionOnScriptError(false);
webClient.getOptions().setThrowExceptionOnFailingStatusCode(false);
webClient.getOptions().setPrintContentOnFailingStatusCode(false);
webClient.getOptions().setJavaScriptEnabled(false);
webClient.getOptions().setCssEnabled(false);
webClient.setCssErrorHandler(new SilentCssErrorHandler());
webClient.getOptions().setRedirectEnabled(true);
webClient.getOptions().setTimeout(10000);
return webClient;
}
};
driver.get(" http://us.24h.com.vn/");
Hi!
I'm having some problems using the driver in a java application, the method get the second time i use it, does not load the page. I'm working on a linux 3.10 machine with java 1.8 and i have the latest distribution of selenium 3.3.1. Here's some the code which im having problems:
DesiredCapabilities cap = new DesiredCapabilities(); cap.setCapability(CapabilityType.PROXY, proxy); cap.setJavascriptEnabled(true); driver = new HtmlUnitDriver(cap); driver.get("http://data.theice.com/MyAccount/Login.aspx?ReturnUrl=~\\ViewData\\Default.aspx");
(... Use some elements...)
Here i simulate a log in process filling the info. and submit the info.
driver.get("http://data.theice.com/ViewData/EndOfDay/FuturesReport.aspx");
<-- Here does not load and remain in the first page.
System.out.println(driver.getTitle());
I tested this solution on a windows machine and it worked normally, however in the linux machine it doesnt load.
I hope you can help me with this problem,
Thank you.
Hi, i am trying to retrieve a list of elements in a xml page using xpath. The method findElementsByXPath returns an empty list if the page is not a HtmlPage:
if (!(lastPage() instanceof HtmlPage)) {
return new ArrayList<>();
}
But the method findElementByXPath works fine cause it checks if it is a SgmlPage:
if (!(lastPage() instanceof SgmlPage)) {
throw new IllegalStateException("Unable to locate element by xpath for " + lastPage());
}
Is there a reason to this behaviour? the node retrieved in findElementByXPath is a DomNode, and i guess the nodes that would be retrieved by findElementsByXPath are too...
In firefox driver the list of nodes are retrieved.
thanks
Since release 2.21 the browser does not support frames (or at least this is the message in the body):
You must use a browser that supports frames
Other actions as typing, clicking are working as expected until a frame element should be located.
My current setup with maven is:
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>2.53.1</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>htmlunit-driver</artifactId>
<version>2.23</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-support</artifactId>
<version>2.53.1</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty.websocket</groupId>
<artifactId>websocket-client</artifactId>
<version>9.4.0.M1</version>
</dependency>
The last version which works OK with frames is 2.20.
Thanks
Please note HtmlUnit 2.22 is released, and we should also release HtmlUnitDriver 2.22.
As a side note, I guess we should have HtmlUnitDriver mentioned in download page.
See the changes in: SeleniumHQ/selenium@bf47492
When searching for elements, HtmlUnitDriver obeys the configured implicit wait timeout. However, there are some small issues/inconsistencies.
Sorry guys:
This is a totally noob question, but I can't make selenium run with htmlunit-driver. I'm using Linux and this is my command line:
java -cp selenium-server-standalone-3.0.0-beta3.jar:htmlunit-driver-standalone-2.21.jar org.openqa.grid.selenium.GridLauncher
The output is this:
Error: Could not find or load main class org.openqa.grid.selenium.GridLauncher
This is the output of java -version
java version "1.8.0_60"
Java(TM) SE Runtime Environment (build 1.8.0_60-b27)
Java HotSpot(TM) 64-Bit Server VM (build 25.60-b23, mixed mode)
What I'm doing wrong?
Thanks in advance
Nomar
Currently there is no way to customize CredentialsProvider used by the WebClient. It makes difficult to configure for example a NTLM authentication or Digest authentication.
When simply trying to drag and drop an element in a page at htmlunit-driver:
new Actions(driver)).dragAndDropBy(element, 10, 10)
.build()
.perform();
we have the following exception:
Exception in thread "main" java.lang.UnsupportedOperationException: Moving to arbitrary X,Y coordinates not supported.
At class HtmlUnitMouse
we have:
@Override
public void mouseMove(Coordinates where, long xOffset, long yOffset) {
throw new UnsupportedOperationException("Moving to arbitrary X,Y coordinates not supported.");
}
Is there any way to do such this thing in htmlunit-driver?
Hello,
I'm working on a headless browser test. I'm stuck on login with google account.
Here is my code:
HtmlUnitDriver driver = new HtmlUnitDriver(BrowserVersion.FIREFOX_38);
driver.get("https://play.google.com/apps/publish");
WebElement name = driver.findElement(EMAIL_TEXTBOX);
name.sendKeys("[my email address]");
And I can seems to send my login account to EMAIL_TEXTBOX, when I call name.getAttribute("value") it returns an empty string, so is name.getText().
This issue is similar to "#46".
When button component is like :
CSS : .hideOnLoad{
display:none
}
Now firefox webdriver could able to click above button with jquery
$('#viewTarget').click();
Where as in HtmlUnitDriver version 2.26 and 2.27 its not able to click the button.
Please provide the solution for this. My email id is : [email protected]
Regards
Ramneesh
HTMLUNIT will fail to navigate and parse to an XML (or HTML Page) that has a Byte Order Mark (BOM).
An XML document in UTF-8 with BOM will yield the following error message in HTMLUnit:
"Failed Parsing XML Document. : Content is not allowed in prolog.
XML with a BOM is considered legal/valid XML and should be parsed by HTMLUnit. See attached file for example
To replicate:
driver = webdriver.Remote(remote_host_name, webdriver.DesiredCapabilities.HTMLUNITWITHJS)
driver.get(file:///C:/bomtest.xml)
Note error
HtmlUnitWebElement.getAttribute("outerHTML")
returns null
. Instead it should return the markup including the element's tag markup (other browsers have WebElement.getAttribute("outerHTML")
).
Add the following code to a Java file:
@Test
public void testOuterHtml() {
WebDriver webDriver = new HtmlUnitDriver(BrowserVersion.FIREFOX_45);
webDriver.get("http://google.com");
WebElement head = webDriver.findElement(By.xpath("//head"));
System.out.println("-------------------------------------");
System.out.println("innerHTML = ");
System.out.println(head.getAttribute("innerHTML"));
System.out.println("-------------------------------------");
System.out.println("outerHTML = ");
System.out.println(head.getAttribute("outerHTML"));
}
Run the test.
If the bug still exists, the following output will appear:
-------------------------------------
outerHTML =
null
If the bug is fixed, the following output will appear:
-------------------------------------
outerHTML =
<head>
<!-- ...snipped for brevity... -->
</head>
Related to this, it seems like "innerHTML"
is actually implemented as "outerHTML"
since it outputs the markup with the outer tags as well.
See:
Hi all,
The tests in htmlunit-driver
don't have all the tests from the Selenium project.
I guess should be references/copied, so failing tests could be fixed.
An example of sharing test code in maven is here.
I was trying to use
org.seleniumhq.selenium:htmlunit-driver:2.25
org.seleniumhq.selenium:selenium-remote-driver:3.1.0
with Dependency convergence enabled in maven but I couldn't.
WARNING]
Dependency convergence error for org.apache.httpcomponents:httpmime:4.5.3 paths to dependency are:
+-com.codenvy.qa:qa-core:1.0-SNAPSHOT
+-org.seleniumhq.selenium:htmlunit-driver:2.25
+-net.sourceforge.htmlunit:htmlunit:2.25
+-org.apache.httpcomponents:httpmime:4.5.3
and
+-com.codenvy.qa:qa-core:1.0-SNAPSHOT
+-org.seleniumhq.selenium:selenium-remote-driver:3.1.0
+-org.apache.httpcomponents:httpmime:4.5.2
[WARNING]
Dependency convergence error for net.sourceforge.htmlunit:htmlunit:2.25 paths to dependency are:
+-com.codenvy.qa:qa-core:1.0-SNAPSHOT
+-org.seleniumhq.selenium:htmlunit-driver:2.25
+-net.sourceforge.htmlunit:htmlunit:2.25
and
+-com.codenvy.qa:qa-core:1.0-SNAPSHOT
+-org.seleniumhq.selenium:selenium-java:3.1.0
+-net.sourceforge.htmlunit:htmlunit:2.23
We are using HtmlUnitDriver to run many tests in parallel, usually about 40.
With HtmlUnitDriver 2.23.2, a maximum heap of 6 GB was enough for that purpose. Now that we switched to 2.26, we are getting OutOfMemoryErrors.
I reduced parallelity down to 25 test threads and went up to 10 GB max heap. Still, heap is always full, garbage collection running non-stop but no free memory can be allocated.
When I'm looking at the heap, the class which uses most of the heap ist net.sourceforge.htmlunit.corejs.javascript.ScriptableObject with several million instances.
Strange thing is, we have JavaScript disabled in the WebClient, so I don't even see why all these instances are necessary.
I am developing a Groovy application, using selenium-webdriver-driver-2.52. I also have the following libraries at use: httpclient 4.5.1 and htmlunit 2.18.
There is an element on the webpage:
<a class="btn btn-lg btn-success" href="#" role="button" type="button" ng-click="login()">Login</a>
WebClient webClient = new WebClient()
webClient.setJavaScriptEnabled(true)
webClient.setThrowExceptionOnFailingStatusCode(false)
webClient.setThrowExceptionOnScriptError(false)
HtmlPage currentPage
currentPage = (HtmlPage) webClient.getPage(<URL>);
List<HtmlAnchor> anchors = currentPage.getAnchors()
HtmlAnchor anchor = anchors[0]
HtmlPage newPage = anchor.click()
The web client is able to locate the anchor, using getAnchors on the current page. However, when I invoke the click button on the anchor, the returned Page is the same as the one I am currently on. The expected behavior however, is that clicking on the button would take me to the next page.
Also, one observation is that the HREF is a hashtag, but when I hover over this in a browser, I can see the actual URL I am after.
Also, the web frontend I am navigating to using selenium makes use of AngularJS - not sure if this could be affecting anything.
Hello,
Could anyone point me - how can I run selenium in standalone mode with HtmlUnitDriver? I have tried the following but without success
# java -cp ".;./libs/" -jar selenium-2.53.0.jar -Dwebdriver.chrome.driver=chromedriver
13:09:29.084 INFO - Launching a standalone Selenium Server
13:09:29.338 INFO - Java: Oracle Corporation 25.77-b03
13:09:29.339 INFO - OS: Linux 2.6.32-573.18.1.el6.x86_64 amd64
13:09:29.422 INFO - v2.53.0, with Core v2.53.0. Built from revision 35ae25b
...
13:09:29.657 INFO - Driver class not found: org.openqa.selenium.htmlunit.HtmlUnitDriver
13:09:29.657 INFO - Driver provider org.openqa.selenium.htmlunit.HtmlUnitDriver is not registered
13:09:30.010 INFO - RemoteWebDriver instances should connect to: http://127.0.0.1:4444/wd/hub
13:09:30.010 INFO - Selenium Server is up and running
# ls
chromedriver htmlunit-driver-standalone-2.20.jar libs selenium-2.53.0.jar
# ls ./libs/
htmlunit-driver-standalone-2.20.jar
@Ben1980 commented on Tue Oct 24 2017
OS: Windows 10
Selenium Version: 3.6.0
Browser: HtmlUnitDriver
Browser Version: HtmlUnitDriver 2.27
Should be able to fill input field and read its content.
With artifacts:
org.seleniumhq.selenium:selenium-api:3.6.0
org.seleniumhq.selenium:selenium-java:3.6.0
org.seleniumhq.selenium:htmlunit-driver:2.27
Causing NoSuchMethodError: com.gargoylesoftware.htmlunit.html.Keyboard and getAttribute("value") returns empty string.
With artifacts:
org.seleniumhq.selenium:selenium-api:2.53.1
org.seleniumhq.selenium:selenium-java:2.53.1
Everthing is fine.
Just get sources from Example and run it with gradlew.bat build or in your IDE
OS: Windows 10
Selenium Version: 3.0.0-beta2 or 2.53.1 (problem occurs with both)
Driver: HtmlUnitDriver
Version: 2.21
Only the memory necessary to run one page should be used.
Memory use keeps on growing, reached 3GB in 30 minutes
When using HtmlUnitDriver with JavaScript enabled, every single time a page is refreshed via
driver.navigate().refresh();
the memory usage grows and grows without bound.
The issue is most extreme when refreshing on sites with lots of javascript, however it is still visible with small html-only sites.
After htmlunit-driver-standalone-2.21.jar there is no further releases for standalone jar. when it is will released. If so add it to the Release Page
I found bug, when you try to get positions of element.
E.g. Go to this page : http://reality.sme.sk/vsetky-ponuky/
Iterate By cssPath : #offerlist-list div.article-list
Look at position and location of returned webelements -> all are the same. PhantomJS returns positions correctly.
Every browser that I use with (Firefox, Chrome, PhantomJS, and JBrowser) Selenium automatically downloads all images on each page. HtmlUnit
does not download the images. While I appreciate the design choice to avoid downloading images (it certainly seems like it would speed up page loads), this behavior is inconsistent with other browsers and causes HtmlUnit
to fail tests that other browsers pass. I am requesting that a constructor option or (Capabilities
) capability be added to HtmlUnitDriver
to specify that it should automatically download all images (similar to HtmlUnitDriver
's constructor option to enable JavaScript).
One way to accomplish this task would be to run this code every time a new page is encountered:
DomNodeList<DomElement> imageElements = htmlPage.getElementsByTagName("img");
for (DomElement imageElement : imageElements) {
HtmlImage htmlImage = (HtmlImage) imageElement;
try {
// Download the image.
htmlImage.getImageReader();
}
catch (IOException e) {
// do nothing.
}
}
Hello,
I'm trying to run my unit tests w/ project which wraps Selenium 3.0.0-beta3 I'm facing following issue:
This is for HtmlUnit driver 2.23
Caused by: java.lang.NoClassDefFoundError: org/eclipse/jetty/websocket/api/Session
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
at java.lang.Class.getDeclaredMethods(Class.java:1975)
at com.gargoylesoftware.htmlunit.javascript.configuration.AbstractJavaScriptConfiguration.process(AbstractJavaScriptConfiguration.java:197)
at com.gargoylesoftware.htmlunit.javascript.configuration.AbstractJavaScriptConfiguration.getClassConfiguration(AbstractJavaScriptConfiguration.java:172)
at com.gargoylesoftware.htmlunit.javascript.configuration.AbstractJavaScriptConfiguration.buildUsageMap(AbstractJavaScriptConfiguration.java:79)
at com.gargoylesoftware.htmlunit.javascript.configuration.AbstractJavaScriptConfiguration.<init>(AbstractJavaScriptConfiguration.java:59)
at com.gargoylesoftware.htmlunit.javascript.configuration.JavaScriptConfiguration.<init>(JavaScriptConfiguration.java:597)
at com.gargoylesoftware.htmlunit.javascript.configuration.JavaScriptConfiguration.getInstance(JavaScriptConfiguration.java:613)
at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.<init>(JavaScriptEngine.java:133)
at com.gargoylesoftware.htmlunit.WebClient.init(WebClient.java:239)
at com.gargoylesoftware.htmlunit.WebClient.<init>(WebClient.java:213)
at org.openqa.selenium.htmlunit.HtmlUnitDriver.newWebClient(HtmlUnitDriver.java:349)
at org.openqa.selenium.htmlunit.HtmlUnitDriver.createWebClient(HtmlUnitDriver.java:315)
at org.openqa.selenium.htmlunit.HtmlUnitDriver.<init>(HtmlUnitDriver.java:192)
at org.openqa.selenium.htmlunit.HtmlUnitDriver.<init>(HtmlUnitDriver.java:249)
... 40 more
When I downgrade to lastly released HtmlUnit driver I'm getting different error because of Selenium implementation changed.
This is for HtmlUnit driver 2.21
java.lang.NoClassDefFoundError: org/openqa/selenium/remote/SessionNotFoundException
So it seems the HtmlUnit driver 2.23 should be better but I can't figure out why it is asking for Jetty dependency.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.