【发布时间】:2013-04-26 15:58:24
【问题描述】:
我在 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()
}
}
谷歌页面:
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
}
}
Modile:
class SearchModule extends Module {
static content = {
field { $("input", name: "q") }
search { $("input", name: "btnK") }
}
}
请帮助保存/打印当前 URL。
谢谢你!
【问题讨论】: