playframework/playframework — pull request #1962 by magro (2013-10-31 08:20:50+00:00)
Title: Allow to use a configured WebDriver when running with test browser

Helpers.running so far accepted a WebDriver _class_ to instantiate (and configure)
the appropriate WebDriver instance.

This change allows to provide an already configured WebDriver instance.
This makes it possible to e.g. create an HtmlUnitDriver for a specific
browser version, like this:

import org.openqa.selenium.htmlunit._
import com.gargoylesoftware.htmlunit._
val driver = new HtmlUnitDriver(BrowserVersion.FIREFOX_17)
driver.setJavascriptEnabled(true)

running(TestServer(3333), driver) { browser =>
..
}

Actually for me using the BrowserVersion.FIREFOX_17 fixed an issue
with jquery: integration tests failed with

WebDriverException: com.gargoylesoftware.htmlunit.ScriptException: TypeError: Cannot find
function addEventListener in object [object HTMLDocument]. (http://code.jquery.com/jquery-1.10.1.min.js#5)

which is an issue that some people experienced before. Using the firefox webdriver lead to problems on our CI system, and using phantomjs needs prerequisites on CI systems as well AFAICS.
Thus using an appropriately configured HtmlUnitDriver was the smalles possible change that worked.

It would be nice to see this in play, I'm especially interested in seeing this in the 2.2.x branch as well.