我正在进行测试geb,但我遇到了问题.我需要保存/打印当前页面的地址(功能SaveUrl()).
Spock测试:
class TestSpec extends GebReportingSpec {
def "Google"() {
given: "go to google.com"
to GooglePage
when: "we at Google home page"
at GooglePage
then: "Search Yahoo"
Search("Yahoo")
SaveUrl()
}
}
Run Code Online (Sandbox Code Playgroud)
GooglePage:
class GooglePage extends Page {
static url = "http://www.google.by"
static at = { $("title").text() == "Google"}
static content = {
theModule { module SearchModule }
}
def Search(String arg0) {
theModule.field.value(arg0)
theModule.search.click()
}
def SaveUrl() {
// need implement
}
}
Run Code Online (Sandbox Code Playgroud)
Modile:
class SearchModule extends Module {
static content = {
field { $("input", name: "q") }
search { $("input", name: "btnK") }
}
}
Run Code Online (Sandbox Code Playgroud)
请帮助保存/打印当前URL.
谢谢!
erd*_*rdi 11
您可以在WebDriver类上使用当前的url getter.WebDriver实例driver在Browser上存储为属性.所以在Geb Spock测试中,它就像说:
driver.currentUrl
Run Code Online (Sandbox Code Playgroud)
编辑
从Geb 0.9.3开始,目前还有一个url getterBrowser.
| 归档时间: |
|
| 查看次数: |
3808 次 |
| 最近记录: |