这似乎有效:
@Grapes([
@Grab("org.codehaus.geb:geb-core:0.7.2"),
@Grab("org.seleniumhq.selenium:selenium-htmlunit-driver:2.25.0"),
@Grab("org.seleniumhq.selenium:selenium-support:2.25.0"),
@Grab("org.seleniumhq.selenium:selenium-firefox-driver:2.25.0")
])
import geb.Browser
import org.openqa.selenium.firefox.FirefoxDriver
Browser.drive() {
go "http://www.google.com"
}
但是我如何使用FirefoxDriver
而不是HtmlUnitDriver
?这只是启动 Firefox,但所有drive
指令都在HtmlUnitDriver
...中执行
@Grapes([
@Grab("org.codehaus.geb:geb-core:0.7.2"),
@Grab("org.seleniumhq.selenium:selenium-htmlunit-driver:2.25.0"),
@Grab("org.seleniumhq.selenium:selenium-support:2.25.0"),
@Grab("org.seleniumhq.selenium:selenium-firefox-driver:2.25.0")
])
import geb.Browser
import org.openqa.selenium.firefox.FirefoxDriver
def browser = new Browser(driver: new FirefoxDriver())
browser.drive {
go "http://www.google.com"
}