在用GEB做自动化测试时,跳转到一个新页面往往会用at语法,例如在一个SchoolAddPage.groovy里:
class SchoolAddPage extends Page{
static at = {
$(‘.box-title‘).text() == "添加英语天地"
}
}
运行程序时往往会出现如下的错误信息,详细如下。这时别怀疑你是不是选错了对象或者判断出错,也有可能是程序运行太快。可以修改成:
static at = {
waitFor() { $(‘.box-title‘).text() == "添加英语天地" }
}
也许就能解决问题
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 more
时间: 2024-10-19 21:25:55