webdriver - Geb overwrite web driver -
i'm running tests using gradle specifying jvm properties in following manner:
-dgeb.env=dev -dgeb.driver=org.openqa.selenium.htmlunit.htmlunitdriver
this sets driver , configures environment in geb config script. want enable javascript htmlunit after specifying in environment property. more general, want overwrite driver in config script (i'm not interested in setting driver in every test's setup()
block)
i tried putting 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 message tests fail due
java.lang.unsupportedoperationexception: javascript not enabled htmlunitdriver instance
i'm bit surprised you're seeing setting javascript
printed out happens driver closure doesn't called because if use geb.driver
system property geb creates driver internally based on that. suggest either use env create driver in gebconfig.groovy
or use different system property geb.driver
ask given driver impl used , manage driver creation yourself.
Comments
Post a Comment