driverにクロージャを設定する。
そうすると、GebはBrowser.drive(closure)の際にこのクロージャによって初期化されたDriverを使用する。
以下の設定では、htmlUnitはJavaScriptを実行し、ScriptErrorの際にExceptionを投げない、セキュアでないSSL通信を許可する。
設定可能な項目は、WebClientOptionsを参照してね。
GebConfig.groovy
import geb.driver.DriverRegistry
import geb.driver.NameBasedDriverFactory
driver = (Settings.gebDriver)?Settings.gebDriver:'firefox'
if(driver=='htmlunit'){
driver = {
def htmlunitDriver = new NameBasedDriverFactory(classLoader,'htmlunit').getDriver()
htmlunitDriver.webClient.options.setJavaScriptEnabled(true)
htmlunitDriver.webClient.options.setThrowExceptionOnScriptError(false)
htmlunitDriver.webClient.options.setUseInsecureSSL(true)
htmlunitDriver
}
}