8

I'm not an expert in selenium, but I believe I may have uncovered a bug when attempting to use jQuery v2.0.2. When I use jQuery v2.0.2 with my Play Framework 2.2.1 application, instead of the bundled jQuery v.1.9.0, I get the following error when I run "play test":

[error] Driver info: driver.version: HtmlUnitDriver
[error]     at org.openqa.selenium.htmlunit.HtmlUnitDriver.get(HtmlUnitDriver.java:367)
[error]     at org.openqa.selenium.htmlunit.HtmlUnitDriver.get(HtmlUnitDriver.java:346)
[error]     at org.fluentlenium.core.Fluent.goTo(Fluent.java:228)
[error]     at IntegrationTest$1.invoke(IntegrationTest.java:22)
[error]     at IntegrationTest$1.invoke(IntegrationTest.java:20)
[error]     at play.test.Helpers.running(Helpers.java:433)
[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://localhost:3333/assets/javascripts/jquery-2.0.2.min.js#4)

I was able to recreate this error by creating a brand new Play Java project using "play new tmp". After creating the project I was able to "play test" just fine. I then copied jquery-2.0.2.min.js into the public/javascripts folder. I then updated the main.scala.html file to use jquery-2.0.2.min.js instead of the bundled jquery-1.9.0.min.js. That was enough to cause this exact error again by running "play test".

I also tried using the FIREFOX WebDriver helper class but again, no luck.

Any insight into how we can get Selenium / Fluentlenium work with the 2.0.2 version of jQuery would be greatly appreciated :) thanks!

2
  • Same problem. If anything new, tell us about it :) Commented Feb 28, 2014 at 18:09
  • See sourceforge.net/p/htmlunit/bugs/1615/#50f4 -- the problem is htmlunit defaults to IE8 which jquery 2 does not support Commented Nov 15, 2015 at 20:38

2 Answers 2

3
+25

According to the Selenium Wiki, The HtmlUnitDriver emulates the JS behavior of (real) browsers. You may change the behavior by changing the browser it emulates. This might help as a workaround for your problem. As they state, the JS (and DOM) implementation of the HtmlUnitBrowser is not complete and bugs/problems, like the one you encountered may happen.

If possible try to work with another browser (Firefox or chrome?) and check if the Website works correctly when you open it in the browser. Open the javascript console (or Firebug if you use Firefox) and double check if your jQuery version works properly.

Sign up to request clarification or add additional context in comments.

Comments

0

This bug is discussed here: https://github.com/playframework/playframework/issues/2607

It is marked closed for current versions of both Play and HtmlUnit, but so far I haven't been able to get things to work without downgrading to JQuery 1.x.

3 Comments

I included the link only to support my succinct and to the point summary of the situation as I see it: 1) It's a known bug. 2) It's been marked closed in both systems concerned. 3) I still can't get things to work without the workaround I specify. You may go ahead and delete the link and my point will still stand fine.
What is meant is that post the relevant part in your answer, if the link dies, then the answer will become useless.
See github.com/playframework/playframework/issues/5050 which is open. Also see sourceforge.net/p/htmlunit/bugs/1615/#50f4 -- the problem is htmlunit defaults to IE8 which jquery 2 does not support

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.