selenium webdriver - Fluentlenium se bloquea en jquery en el marco de juego
selenium-webdriver (1)
Quiero escribir pruebas de Fluentlenium pero se bloquea en jQuery. Utilizo la integración estándar en el marco de juego. Intento que el ejemplo estándar simple funcione. Si realizo la prueba, obtengo (lo más importante)
Caused by: com.gargoylesoftware.htmlunit.ScriptException: TypeError: Cannot find function addEventListener in object [object HTMLDocument]. (http://cg.ch:3333/vassets/lib/jquery/jquery.min.js#2)
Caused by: net.sourceforge.htmlunit.corejs.javascript.EcmaError: TypeError: Cannot find function addEventListener in object [object HTMLDocument]. (http://cg.ch:3333/vassets/lib/jquery/jquery.min.js#2)
Estoy usando jQuery v2.1.3.
¿Algunas ideas?
Este es el rastro completo:
[error] Driver info: driver.version: HtmlUnitDriver, took 6.175 sec
[error] at org.openqa.selenium.htmlunit.HtmlUnitDriver.get(HtmlUnitDriver.java:484)
[error] at org.openqa.selenium.htmlunit.HtmlUnitDriver.get(HtmlUnitDriver.java:463)
[error] at org.fluentlenium.core.Fluent.goTo(Fluent.java:336)
[error] at IntegrationTest$1.invoke(IntegrationTest.java:22)
[error] at IntegrationTest$1.invoke(IntegrationTest.java:20)
[error] at play.test.Helpers.running(Helpers.java:555)
[error] at play.test.Helpers.running(Helpers.java:541)
[error] at IntegrationTest.test(IntegrationTest.java:20)
[error] ...
[error] Caused by: com.gargoylesoftware.htmlunit.ScriptException: TypeError: Cannot find function addEventListener in object [object HTMLDocument]. (http://cg.ch:3333/vassets/lib/jquery/jquery.min.js#2)
[error] at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$HtmlUnitContextAction.run(JavaScriptEngine.java:684)
[error] at net.sourceforge.htmlunit.corejs.javascript.Context.call(Context.java:602)
[error] at net.sourceforge.htmlunit.corejs.javascript.ContextFactory.call(ContextFactory.java:507)
[error] at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.execute(JavaScriptEngine.java:570)
[error] at com.gargoylesoftware.htmlunit.html.HtmlPage.loadExternalJavaScriptFile(HtmlPage.java:1062)
[error] at com.gargoylesoftware.htmlunit.html.HtmlScript.executeScriptIfNeeded(HtmlScript.java:409)
[error] at com.gargoylesoftware.htmlunit.html.HtmlScript$3.execute(HtmlScript.java:266)
[error] at com.gargoylesoftware.htmlunit.html.HtmlScript.onAllChildrenAddedToPage(HtmlScript.java:286)
[error] at com.gargoylesoftware.htmlunit.html.HTMLParser$HtmlUnitDOMBuilder.endElement(HTMLParser.java:683)
[error] at org.apache.xerces.parsers.AbstractSAXParser.endElement(Unknown Source)
[error] at com.gargoylesoftware.htmlunit.html.HTMLParser$HtmlUnitDOMBuilder.endElement(HTMLParser.java:642)
[error] at org.cyberneko.html.HTMLTagBalancer.callEndElement(HTMLTagBalancer.java:1170)
[error] at org.cyberneko.html.HTMLTagBalancer.endElement(HTMLTagBalancer.java:1072)
[error] at org.cyberneko.html.filters.DefaultFilter.endElement(DefaultFilter.java:206)
[error] at org.cyberneko.html.filters.NamespaceBinder.endElement(NamespaceBinder.java:330)
[error] at org.cyberneko.html.HTMLScanner$ContentScanner.scanEndElement(HTMLScanner.java:3116)
[error] at org.cyberneko.html.HTMLScanner$ContentScanner.scan(HTMLScanner.java:2083)
[error] at org.cyberneko.html.HTMLScanner.scanDocument(HTMLScanner.java:918)
[error] at org.cyberneko.html.HTMLConfiguration.parse(HTMLConfiguration.java:499)
[error] at org.cyberneko.html.HTMLConfiguration.parse(HTMLConfiguration.java:452)
[error] at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
[error] at com.gargoylesoftware.htmlunit.html.HTMLParser$HtmlUnitDOMBuilder.parse(HTMLParser.java:899)
[error] at com.gargoylesoftware.htmlunit.html.HTMLParser.parse(HTMLParser.java:242)
[error] at com.gargoylesoftware.htmlunit.html.HTMLParser.parseHtml(HTMLParser.java:188)
[error] at com.gargoylesoftware.htmlunit.DefaultPageCreator.createHtmlPage(DefaultPageCreator.java:268)
[error] at com.gargoylesoftware.htmlunit.DefaultPageCreator.createPage(DefaultPageCreator.java:156)
[error] at com.gargoylesoftware.htmlunit.WebClient.loadWebResponseInto(WebClient.java:437)
[error] at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:311)
[error] at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:376)
[error] at org.openqa.selenium.htmlunit.HtmlUnitDriver.get(HtmlUnitDriver.java:474)
[error] ... 41 more
[error] Caused by: net.sourceforge.htmlunit.corejs.javascript.EcmaError: TypeError: Cannot find function addEventListener in object [object HTMLDocument]. (http://cg.ch:3333/vassets/lib/jquery/jquery.min.js#2)
[error] at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3603)
[error] at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3587)
[error] at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.typeError(ScriptRuntime.java:3608)
[error] at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.typeError2(ScriptRuntime.java:3624)
[error] at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.notFunctionError(ScriptRuntime.java:3688)
[error] at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.getPropFunctionAndThisHelper(ScriptRuntime.java:2207)
[error] at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.getPropFunctionAndThis(ScriptRuntime.java:2189)
[error] at net.sourceforge.htmlunit.corejs.javascript.Interpreter.interpretLoop(Interpreter.java:1333)
[error] at net.sourceforge.htmlunit.corejs.javascript.Interpreter.interpret(Interpreter.java:798)
[error] at net.sourceforge.htmlunit.corejs.javascript.InterpretedFunction.call(InterpretedFunction.java:105)
[error] at net.sourceforge.htmlunit.corejs.javascript.ContextFactory.doTopCall(ContextFactory.java:405)
[error] at com.gargoylesoftware.htmlunit.javascript.HtmlUnitContextFactory.doTopCall(HtmlUnitContextFactory.java:309)
[error] at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3031)
[error] at net.sourceforge.htmlunit.corejs.javascript.InterpretedFunction.exec(InterpretedFunction.java:115)
[error] at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$3.doRun(JavaScriptEngine.java:561)
[error] at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$HtmlUnitContextAction.run(JavaScriptEngine.java:669)
[error] ... 70 more
[error] Failed: Total 2, Failed 1, Errors 0, Passed 1
[error] Failed tests:
[error] IntegrationTest
[error] (root/test:test) sbt.TestsFailedException: Tests unsuccessful
[error] Total time: 8 s, completed Mar 5, 2015 11:17:06 AM
El error ocurre porque el navegador de prueba play.test.Helpers.HTMLUNIT tiene JavaScript habilitado y encuentra errores en el origen del script de jQuery. La única solución alternativa que he encontrado es deshabilitar JavaScript en el controlador de prueba.
Entonces, en lugar de invocar tu prueba,
running(testServer(3333,fake), HTMLUNIT, new Callback<TestBrowser>() {
public void invoke(TestBrowser browser) throws JAXBException, IOException {
Deberías hacer
running(testServer(3333,fake), new HtmlUnitDriver(), new Callback<TestBrowser>() {
public void invoke(TestBrowser browser) throws JAXBException, IOException {
Por supuesto, tenga en cuenta que si hace esto, no debe esperar que se ejecute el código JavaScript en su página dentro del navegador de prueba.