在用GEB作自動化測試時,跳轉到一個新頁面每每會用at語法,例如在一個SchoolAddPage.groovy裏:
class SchoolAddPage extends Page{
static at = {
$('.box-title').text() == "添加英語天地"
}
}
運行程序時每每會出現以下的錯誤信息,詳細以下。這時別懷疑你是否是選錯了對象或者判斷出錯,也有多是程序運行太快。能夠修改爲:
static at = {
waitFor() { $('.box-title').text() == "添加英語天地" }
}
也許就能解決問題ide
geb.error.UnexpectedPageException: At checker page verification failed for page page.SchoolAddPage
at geb.navigator.NonEmptyNavigator.click(NonEmptyNavigator.groovy:492)
at geb.navigator.NonEmptyNavigator.click(NonEmptyNavigator.groovy:469)
at geb.content.TemplateDerivedPageContent.click(TemplateDerivedPageContent.groovy:71)
SchoolManageSpec.to add a school page(SchoolManageSpec.groovy:59)
Caused by: Assertion failed:測試
$('.box-title').text() == "添加英語天地"
| | |
[] null false對象
at page.SchoolAddPage._clinit__closure2(SchoolAddPage.groovy:8)
at cn.com.nd.school.page.SchoolAddPage._clinit__closure2(SchoolAddPage.groovy)
at geb.Page.verifyThisPageAtOnly(Page.groovy:228)
at geb.Page.verifyAt(Page.groovy:182)
at geb.Browser.methodMissing(Browser.groovy:206)
at geb.navigator.NonEmptyNavigator.click(NonEmptyNavigator.groovy:481)
... 3 moreit