【发布时间】:2014-04-24 05:44:39
【问题描述】:
我正在运行一个简单的 Geb 测试,如下所示:
class IndexPage extends Page {
//static url = "http://localhost:8080/sampleGrailsApp"
static at = { title == "sampleGrailsApp" }
static content = {
signInButton { $("div", 0, class: "container-fluid").find("button", 0) }
modalFooterSignInButton(wait: true, to: MyPage) { $("footer", 0, class: "modal-footer").find("input", 0, class: "btn-primary") }
modalFooterUsernameInput { $("form").username = it }
modalFooterPasswordInput { $("form").password = it }
signIn { username, password ->
signInButton.click()
waitFor { modalFooterSignInButton.present }
modalFooterUsernameInput username
modalFooterPasswordInput password
modalFooterSignInButton.click()
}
}
}
在我的测试中,页面调用如下:
def "sigin"() {
given: "User is at index page"
at IndexPage
when: "User signs in"
signIn "username","password"
then: "Goes to MyPage"
at MyPage
}
在某些情况下,modalFooterSignInButton.click() 发生在用户名完全输入之前,因此测试失败。有没有人遇到过这个?如何在点击激活之前等待输入完成?我正在使用 Geb 0.9.2。
提前致谢。
【问题讨论】: