I'm running my tests using gradle which is specifying JVM properties in the following manner:
-Dgeb.env=dev -Dgeb.driver=org.openqa.selenium.htmlunit.HtmlUnitDriver
This sets driver and configures environment in Geb config script.
I want to enable JavaScript for HtmlUnit after specifying it in environment property. To be more general, I want to overwrite driver in the config script (I'm not interested in setting driver in every test's setup()
block)
I tried putting the following code snippet in Geb config script:
if (System.getProperty("geb.driver")=="org.openqa.selenium.htmlunit.HtmlUnitDriver") {
driver = {
println "Setting JavaScript"
def driver = new HtmlUnitDriver()
driver.setJavascriptEnabled(true)
driver
}
}
This prints out the message but the tests fail due to
java.lang.UnsupportedOperationException: Javascript is not enabled for this HtmlUnitDriver instance