java - What is the use of providing browser version in HtmlUnitDriver -


i trying run selenium webdriver in linux machine. tried use htmlunitdriver achieve this.

i getting following error while executing jquery.

typeerror: cannot find function addeventlistener in object [object htmldocument]. (http://localhost/xxx/js_lib/jquery2/jquery-2.1.0.min.js#2) 

the above exception occured when htmlunitdriver used without browser version below,

htmlunitdriver driver = new htmlunitdriver(); driver.setjavascriptenabled(true); 

also junit test case getting failed following reason,

org.openqa.selenium.nosuchelementexception: unable locate element id: abcde 

if pass browser version below,

htmlunitdriver driver = new htmlunitdriver(browserversion.firefox_38); driver.setjavascriptenabled(true); 

the test case getting pass, exception thrown in console like,

severe: job run failed unexpected runtimeexception: exception invoking window.getcomputedstyle() arguments [text, string] ======= exception start ======== exception class=[java.lang.illegalargumentexception] com.gargoylesoftware.htmlunit.scriptexception: exception invoking window.getcomputedstyle() arguments [text, string]     @ com.gargoylesoftware.htmlunit.javascript.javascriptengine$htmlunitcontextaction.run(javascriptengine.java:847)     @ net.sourceforge.htmlunit.corejs.javascript.context.call(context.java:628)     @ net.sourceforge.htmlunit.corejs.javascript.contextfactory.call(contextfactory.java:513)     @ com.gargoylesoftware.htmlunit.javascript.javascriptengine.callfunction(javascriptengine.java:779)     @ com.gargoylesoftware.htmlunit.javascript.host.xml.xmlhttprequest.setstate(xmlhttprequest.java:233)     @ com.gargoylesoftware.htmlunit.javascript.host.xml.xmlhttprequest.dosend(xmlhttprequest.java:762)     @ com.gargoylesoftware.htmlunit.javascript.host.xml.xmlhttprequest.access$000(xmlhttprequest.java:104)     @ com.gargoylesoftware.htmlunit.javascript.host.xml.xmlhttprequest$1.run(xmlhttprequest.java:623)     @ net.sourceforge.htmlunit.corejs.javascript.context.call(context.java:628)     @ net.sourceforge.htmlunit.corejs.javascript.contextfactory.call(contextfactory.java:513)     @ com.gargoylesoftware.htmlunit.javascript.background.javascriptxmlhttprequestjob.run(javascriptxmlhttprequestjob.java:36)     @ com.gargoylesoftware.htmlunit.javascript.background.javascriptjobmanagerimpl.runsinglejob(javascriptjobmanagerimpl.java:415)     @ com.gargoylesoftware.htmlunit.javascript.background.defaultjavascriptexecutor.run(defaultjavascriptexecutor.java:167)     @ java.lang.thread.run(thread.java:744) caused by: java.lang.illegalargumentexception: exception invoking window.getcomputedstyle() arguments [text, string]     @ net.sourceforge.htmlunit.corejs.javascript.memberbox.invoke(memberbox.java:193)     @ net.sourceforge.htmlunit.corejs.javascript.functionobject.call(functionobject.java:449)     @ net.sourceforge.htmlunit.corejs.javascript.interpreter.interpretloop(interpreter.java:1536)     @ net.sourceforge.htmlunit.corejs.javascript.interpreter.interpret(interpreter.java:798)     @ net.sourceforge.htmlunit.corejs.javascript.interpretedfunction.call(interpretedfunction.java:105)     @ net.sourceforge.htmlunit.corejs.javascript.contextfactory.dotopcall(contextfactory.java:411)     @ com.gargoylesoftware.htmlunit.javascript.htmlunitcontextfactory.dotopcall(htmlunitcontextfactory.java:309)     @ net.sourceforge.htmlunit.corejs.javascript.scriptruntime.dotopcall(scriptruntime.java:3286)     @ com.gargoylesoftware.htmlunit.javascript.javascriptengine$4.dorun(javascriptengine.java:772)     @ com.gargoylesoftware.htmlunit.javascript.javascriptengine$htmlunitcontextaction.run(javascriptengine.java:832)     ... 13 more caused by: java.lang.illegalargumentexception: java.lang.classcastexception@4d3015e7     @ sun.reflect.generatedmethodaccessor55.invoke(unknown source)     @ sun.reflect.delegatingmethodaccessorimpl.invoke(delegatingmethodaccessorimpl.java:43)     @ java.lang.reflect.method.invoke(method.java:606)     @ net.sourceforge.htmlunit.corejs.javascript.memberbox.invoke(memberbox.java:153)     ... 22 more 

i have following list of questions,

  1. to use firefox browser in htmlunitdriver, need install firefox in linux machine ?
  2. why above exceptions thrown?
  3. is there option run selenium in lunix machine without gui?

i starter in selenium , need valuable thoughts on this. thanks

to use firefox browser in htmlunitdriver, need install firefox in linux machine ?

no, don't need install real browsers.

why above exceptions thrown?

because htmlunit javascript support not accurate sometimes, please read here.

also, please try provide complete details (url or small sample project), others can see same errors.


Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -