HTMLUNIT driver config does not work for example sampler

1,412 views
Skip to first unread message

Jaeho Kim

unread,
Mar 21, 2014, 9:56:34 AM3/21/14
to jmeter-...@googlegroups.com
I am trying to run WebDriver plugin and firefox driver config works fine for the duckduckgo example.. 

but the htmlunit driver gave me full of error,,,

2014/03/21 09:06:56 INFO  - jmeter.threads.JMeterThread: Thread started: Thread Group 1-1 

2014/03/21 09:06:56 INFO  - com.googlecode.jmeter.plugins.webdriver.config.WebDriverConfig: iterationStart() 

2014/03/21 09:06:56 INFO  - com.googlecode.jmeter.plugins.webdriver.sampler.WebDriverSampler: Current thread name: 'Thread Group 1-1', has browser: 'org.openqa.selenium.htmlunit.HtmlUnitDriver@333bdb' 

2014/03/21 09:06:56 ERROR - jmeter.threads.JMeterThread: Test failed! java.lang.NoSuchMethodError: org.apache.http.impl.client.AbstractHttpClient.execute(Lorg/apache/http/HttpHost;Lorg/apache/http/HttpRequest;Lorg/apache/http/protocol/HttpContextLorg/apache/http/client/methods/CloseableHttpResponse;

at com.gargoylesoftware.htmlunit.HttpWebConnection.getResponse(HttpWebConnection.java:167)

at com.gargoylesoftware.htmlunit.WebClient.loadWebResponseFromWebConnection(WebClient.java:1281)

at com.gargoylesoftware.htmlunit.WebClient.loadWebResponse(WebClient.java:119

at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:307)

at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:376)

at org.openqa.selenium.htmlunit.HtmlUnitDriver.get(HtmlUnitDriver.java:474)


It would be great someone gives me a tip how to solve this issue,, 


My sample is below...


var pkg = JavaImporter(org.openqa.selenium)

var support_ui = JavaImporter(org.openqa.selenium.support.ui.WebDriverWait)

var wait = new support_ui.WebDriverWait(WDS.browser, 5000)


WDS.sampleResult.sampleStart()

WDS.browser.get('http://duckduckgo.com')

var searchField = WDS.browser.findElement(pkg.By.id('search_form_input_homepage'))

searchField.click()

searchField.sendKeys(['blazemeter'])

var button = WDS.browser.findElement(pkg.By.id('search_button_homepage'))

button.click()

var link = WDS.browser.findElement(pkg.By.ByCssSelector('#r1-0 > div.links_main > h2 > a.large > b'))

link.click()

WDS.log.info(WDS.name + ' has logged an entry');

WDS.sampleResult.sampleEnd()



vdab...@gmail.com

unread,
Mar 21, 2014, 12:48:42 PM3/21/14
to jmeter-...@googlegroups.com
Hi,

Did you (from documentation) ? :

(Additional) Installation step

JMeter ships with HttpClient v4.2.x, however for the latest HtmlUnit to work properly, it must be upgraded to v4.3.x. So for this to work, the user must remove the following JarFiles from the JMeter lib/ directory:

  1. httpclient-4.2.*.jar
  2. httpcore-4.2.*.jar
  3. httpmime-4.2.*.jar
Message has been deleted

aust...@gmail.com

unread,
Aug 12, 2014, 1:32:25 PM8/12/14
to jmeter-...@googlegroups.com
Vincent,
I tried what you suggest in the previous comment but now I get strange CSS related errors.   The app I am testing is an EmberJS app I think.   Could a certain version of loaded jQuery be causing these problems?

2014/08/12 10:18:01 WARN  - com.gargoylesoftware.htmlunit.IncorrectnessListenerImpl: Obsolete content type encountered: 'text/javascript'.
2014/08/12 10:18:01 WARN  - com.gargoylesoftware.htmlunit.DefaultCssErrorHandler: CSS error: 'http://myapp.com/appq/css/9b7e7cf.css' [1:12712] Error in @media rule. (Invalid token "screen". Was expecting one of: <S>, <LBRACE>, <COMMA>.)
2014/08/12 10:18:01 WARN  - com.gargoylesoftware.htmlunit.DefaultCssErrorHandler: CSS error: 'http://myapp.com/appq/css/9b7e7cf.css' [1:99447] Error in expression. (Invalid token "color-stop(". Was expecting one of: <S>, <NUMBER>, <IDENT>, <STRING>, <PLUS>, <COMMA>, <EMS>, <EXS>, <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>, <PERCENTAGE>, <URI>, "-", "=", ")".)
2014/08/12 10:18:01 INFO  - com.gargoylesoftware.htmlunit.html.InputElementFactory: Bad input type: "search", creating a text input
2014/08/12 10:18:01 INFO  - com.gargoylesoftware.htmlunit.html.InputElementFactory: Bad input type: "tel", creating a text input
2014/08/12 10:18:01 INFO  - com.gargoylesoftware.htmlunit.html.InputElementFactory: Bad input type: "url", creating a text input
2014/08/12 10:18:01 INFO  - com.gargoylesoftware.htmlunit.html.InputElementFactory: Bad input type: "email", creating a text input
2014/08/12 10:18:01 INFO  - com.gargoylesoftware.htmlunit.html.InputElementFactory: Bad input type: "datetime", creating a text input
2014/08/12 10:18:01 INFO  - com.gargoylesoftware.htmlunit.html.InputElementFactory: Bad input type: "date", creating a text input
2014/08/12 10:18:01 INFO  - com.gargoylesoftware.htmlunit.html.InputElementFactory: Bad input type: "month", creating a text input
2014/08/12 10:18:01 INFO  - com.gargoylesoftware.htmlunit.html.InputElementFactory: Bad input type: "week", creating a text input
com.gargoylesoftware.htmlunit.ScriptException: TypeError: Cannot set property [HTMLStyleElement].media that has only a getter to screen. (http://secret/bower_components/respond/dest/respond.src.js#6)
    at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$HtmlUnitContextAction.run(JavaScriptEngine.java:684)
    at net.sourceforge.htmlunit.corejs.javascript.Context.call(Context.java:602)
    at net.sourceforge.htmlunit.corejs.javascript.ContextFactory.call(ContextFactory.java:507)
    at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.callFunction(JavaScriptEngine.java:616)
    at com.gargoylesoftware.htmlunit.javascript.host.xml.XMLHttpRequest.setState(XMLHttpRequest.java:230)
    at com.gargoylesoftware.htmlunit.javascript.host.xml.XMLHttpRequest.doSend(XMLHttpRequest.java:710)
    at com.gargoylesoftware.htmlunit.javascript.host.xml.XMLHttpRequest.access$000(XMLHttpRequest.java:94)
    at com.gargoylesoftware.htmlunit.javascript.host.xml.XMLHttpRequest$1.run(XMLHttpRequest.java:603)
    at net.sourceforge.htmlunit.corejs.javascript.Context.call(Context.java:602)
    at net.sourceforge.htmlunit.corejs.javascript.ContextFactory.call(ContextFactory.java:507)
    at com.gargoylesoftware.htmlunit.javascript.background.JavascriptXMLHttpRequestJob.run(JavascriptXMLHttpRequestJob.java:36)
    at com.gargoylesoftware.htmlunit.javascript.background.JavaScriptJobManagerImpl.runSingleJob(JavaScriptJobManagerImpl.java:328)
    at com.gargoylesoftware.htmlunit.javascript.background.DefaultJavaScriptExecutor.run(DefaultJavaScriptExecutor.java:162)
    at java.lang.Thread.run(Thread.java:744)
Caused by: net.sourceforge.htmlunit.corejs.javascript.EcmaError: TypeError: Cannot set property [HTMLStyleElement].media that has only a getter to screen. (http://secret/bower_components/respond/dest/respond.src.js#6)
    at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3603)
    at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3587)
    at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.typeError(ScriptRuntime.java:3608)
    at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.typeError3(ScriptRuntime.java:3630)
    at com.gargoylesoftware.htmlunit.javascript.SimpleScriptable.isReadOnlySettable(SimpleScriptable.java:462)
    at net.sourceforge.htmlunit.corejs.javascript.ScriptableObject$GetterSlot.setValue(ScriptableObject.java:259)
    at net.sourceforge.htmlunit.corejs.javascript.ScriptableObject.putImpl(ScriptableObject.java:2796)
    at net.sourceforge.htmlunit.corejs.javascript.ScriptableObject.put(ScriptableObject.java:521)
    at net.sourceforge.htmlunit.corejs.javascript.ScriptableObject.putProperty(ScriptableObject.java:2479)
    at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.setObjectProp(ScriptRuntime.java:1569)
    at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.setObjectProp(ScriptRuntime.java:1564)
    at net.sourceforge.htmlunit.corejs.javascript.Interpreter.interpretLoop(Interpreter.java:1253)
    at net.sourceforge.htmlunit.corejs.javascript.Interpreter.interpret(Interpreter.java:798)
    at net.sourceforge.htmlunit.corejs.javascript.InterpretedFunction.call(InterpretedFunction.java:105)
    at net.sourceforge.htmlunit.corejs.javascript.ContextFactory.doTopCall(ContextFactory.java:405)
    at com.gargoylesoftware.htmlunit.javascript.HtmlUnitContextFactory.doTopCall(HtmlUnitContextFactory.java:309)
    at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3031)
    at net.sourceforge.htmlunit.corejs.javascript.InterpretedFunction.call(InterpretedFunction.java:103)
    at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$4.doRun(JavaScriptEngine.java:609)
    at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$HtmlUnitContextAction.run(JavaScriptEngine.java:669)
    ... 13 more
Enclosed exception:
net.sourceforge.htmlunit.corejs.javascript.EcmaError: TypeError: Cannot set property [HTMLStyleElement].media that has only a getter to screen. (http://secret/bower_components/respond/dest/respond.src.js#6)
    at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3603)
    at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3587)
    at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.typeError(ScriptRuntime.java:3608)
    at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.typeError3(ScriptRuntime.java:3630)
    at com.gargoylesoftware.htmlunit.javascript.SimpleScriptable.isReadOnlySettable(SimpleScriptable.java:462)
    at net.sourceforge.htmlunit.corejs.javascript.ScriptableObject$GetterSlot.setValue(ScriptableObject.java:259)
    at net.sourceforge.htmlunit.corejs.javascript.ScriptableObject.putImpl(ScriptableObject.java:2796)
    at net.sourceforge.htmlunit.corejs.javascript.ScriptableObject.put(ScriptableObject.java:521)
    at net.sourceforge.htmlunit.corejs.javascript.ScriptableObject.putProperty(ScriptableObject.java:2479)
    at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.setObjectProp(ScriptRuntime.java:1569)
    at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.setObjectProp(ScriptRuntime.java:1564)
    at net.sourceforge.htmlunit.corejs.javascript.Interpreter.interpretLoop(Interpreter.java:1253)
    at script(http://secret/bower_components/respond/dest/respond.src.js:6)
    at script(http://secret/bower_components/respond/dest/respond.src.js:7)
    at script(http://secret/bower_components/respond/dest/respond.src.js:7)
    at script(http://secret/bower_components/respond/dest/respond.src.js:2)
    at net.sourceforge.htmlunit.corejs.javascript.Interpreter.interpret(Interpreter.java:798)
    at net.sourceforge.htmlunit.corejs.javascript.InterpretedFunction.call(InterpretedFunction.java:105)
    at net.sourceforge.htmlunit.corejs.javascript.ContextFactory.doTopCall(ContextFactory.java:405)
    at com.gargoylesoftware.htmlunit.javascript.HtmlUnitContextFactory.doTopCall(HtmlUnitContextFactory.java:309)
    at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3031)
    at net.sourceforge.htmlunit.corejs.javascript.InterpretedFunction.call(InterpretedFunction.java:103)
    at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$4.doRun(JavaScriptEngine.java:609)
    at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$HtmlUnitContextAction.run(JavaScriptEngine.java:669)
    at net.sourceforge.htmlunit.corejs.javascript.Context.call(Context.java:602)
    at net.sourceforge.htmlunit.corejs.javascript.ContextFactory.call(ContextFactory.java:507)
    at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.callFunction(JavaScriptEngine.java:616)
    at com.gargoylesoftware.htmlunit.javascript.host.xml.XMLHttpRequest.setState(XMLHttpRequest.java:230)
    at com.gargoylesoftware.htmlunit.javascript.host.xml.XMLHttpRequest.doSend(XMLHttpRequest.java:710)
    at com.gargoylesoftware.htmlunit.javascript.host.xml.XMLHttpRequest.access$000(XMLHttpRequest.java:94)
    at com.gargoylesoftware.htmlunit.javascript.host.xml.XMLHttpRequest$1.run(XMLHttpRequest.java:603)
    at net.sourceforge.htmlunit.corejs.javascript.Context.call(Context.java:602)
    at net.sourceforge.htmlunit.corejs.javascript.ContextFactory.call(ContextFactory.java:507)
    at com.gargoylesoftware.htmlunit.javascript.background.JavascriptXMLHttpRequestJob.run(JavascriptXMLHttpRequestJob.java:36)
    at com.gargoylesoftware.htmlunit.javascript.background.JavaScriptJobManagerImpl.runSingleJob(JavaScriptJobManagerImpl.java:328)
    at com.gargoylesoftware.htmlunit.javascript.background.DefaultJavaScriptExecutor.run(DefaultJavaScriptExecutor.java:162)
    at java.lang.Thread.run(Thread.java:744)
== CALLING JAVASCRIPT ==

  function () {
      4 !== a.readyState || 200 !== a.status && 304 !== a.status || b(a.responseText);
  }

======= EXCEPTION END ========

ritesh.n...@gmail.com

unread,
Oct 7, 2014, 9:10:33 AM10/7/14
to jmeter-...@googlegroups.com
 upgraded to jars to v4.3.x..and it works like a charm now :-) ...Thanks a lot for this post.

closebrothe...@gmail.com

unread,
Dec 18, 2016, 2:13:40 AM12/18/16
to jmeter-plugins, ritesh.n...@gmail.com
Hi Vincent,

I have the upgraded version httpclien-4.5.2 still i am getting the script error. Any Idea.

v.raje...@gmail.com

unread,
Jul 17, 2017, 3:21:54 PM7/17/17
to jmeter-plugins, ritesh.n...@gmail.com, closebrothe...@gmail.com
Hi, 
I am even trying to run a sample test on HTMLUNITDriver Config.

Below is 
var pkg=JavaImporter(org.openqa.selenium,org.openqa.selenium.support.ui) //import java selenium packages
var pkg1=JavaImporter(org.openqa.selenium.htmlunit.HtmlUnitDriver,org.openqa.selenium.interactions.Actions)
var Thr=JavaImporter(java.lang.Thread)//import Thread sleep packages
//var driver = new HtmlUnitDriver()
HtmlUnitDriver driver = new HtmlUnitDriver(BrowserVersion.INTERNET_EXPLORER_11)
var wait = new support_ui.WebDriverWait(WDS.browser, 50000)
//var wait = new pkg.HtmlUnitDriverWait(WDS.browser,60) //import WebDriverWait Package
WDS.sampleResult.sampleStart() //sample starting point

Below is the Error:
=============
javax.script.ScriptException: sun.org.mozilla.javascript.internal.EvaluatorException: missing ; before statement (<Unknown source>#5) in <Unknown source> at line number 5
at com.sun.script.javascript.RhinoScriptEngine.eval(Unknown Source)
at com.sun.script.javascript.RhinoScriptEngine.eval(Unknown Source)
at javax.script.AbstractScriptEngine.eval(Unknown Source)
at com.googlecode.jmeter.plugins.webdriver.sampler.WebDriverSampler.sample(WebDriverSampler.java:76)
at org.apache.jmeter.threads.JMeterThread.executeSamplePackage(JMeterThread.java:475)
at org.apache.jmeter.threads.JMeterThread.processSampler(JMeterThread.java:418)
at org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:249)
at java.lang.Thread.run(Unknown Source)

any suggestions what am i missing. ?? i have downloaded all the .jars as per the help doc "https://jmeter-plugins.org/wiki/HtmlUnitDriverConfig/"
Below are the jars have in Lib folder. 
  1. httpclient-4.5.*.jar
  2. httpcore-4.4.*.jar
  3. httpmime-4.5.*.jar

Andrey Pokhilko

unread,
Jul 18, 2017, 2:59:09 AM7/18/17
to jmeter-...@googlegroups.com

I think HTMLUnit can be replaced with PhantomJS driver, no? Could work.

Andrey Pokhilko

--
You received this message because you are subscribed to the Google Groups "jmeter-plugins" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jmeter-plugin...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages