Geb 中的@current_page 功能
@current_page feature in Geb
在 WATIR
中,每当我们登陆到在 运行 时间创建的页面(在测试用例执行期间)时,我们使用 @current_page
。
我正在寻找 Geb
中的类似功能。
这里我有两个页面
RegistrationPage.groovy
我提供的地方
static url = "/register.html"
我还有UserProfilePage.groovy
这里我不能提供任何 static url
因为它是在我提交注册页面后创建的,它会根据用户名更改
示例https://xxxxx.com/paul.html, if two paul's are there then https://xxxxx.com/paul2.html
我想用
static content = {
defaultprofilePic {$("#userprofilepic")}
}
在 UserProfilePage.groovy
中声明
如果我不使用 to
关键字,它会让我回到 baseURL,如果我使用它,则会给出异常,该元素在此页面上不可用。
但我想如果我使用像@current_page这样的东西它会通过
您应该使用 at(UserProfilePage)
将当前页面设置为 UserProfilePage
的实例并验证其 at checker.
在 WATIR
中,每当我们登陆到在 运行 时间创建的页面(在测试用例执行期间)时,我们使用 @current_page
。
我正在寻找 Geb
中的类似功能。
这里我有两个页面
RegistrationPage.groovy 我提供的地方
static url = "/register.html"
我还有UserProfilePage.groovy
这里我不能提供任何 static url
因为它是在我提交注册页面后创建的,它会根据用户名更改
示例https://xxxxx.com/paul.html, if two paul's are there then https://xxxxx.com/paul2.html
我想用
static content = {
defaultprofilePic {$("#userprofilepic")}
}
在 UserProfilePage.groovy
如果我不使用 to
关键字,它会让我回到 baseURL,如果我使用它,则会给出异常,该元素在此页面上不可用。
但我想如果我使用像@current_page这样的东西它会通过
您应该使用 at(UserProfilePage)
将当前页面设置为 UserProfilePage
的实例并验证其 at checker.