【发布时间】:2013-08-22 15:34:05
【问题描述】:
我使用 Geb 进行了以下 Spock 测试:
def "The session should expire when the browser is closed."() {
given:
to LoginPage
expect:
waitFor { at LoginPage }
when:
auth.login(Constants.USERNAME)
then:
waitFor { at DashboardPage }
when:
browser.close()
// ???
to SetupAccountPage //fails with SessionNotFoundException: Session ID is null
then:
waitFor { at LoginPage }
}
在测试中关闭和重新打开浏览器的正确方法是什么?
顺便说一句 - 我知道 this question,但我不想手动显式注销或清除 cookie,因为这是该测试正在验证的内容。
【问题讨论】:
-
设置一个查看
about:blank,然后查看to BlankPage ; to SetupAccountPage而不是browser.close()的页面是否有效? -
谢谢蒂姆。不,它不起作用...会话 cookie 没有被删除,因此测试失败,因为用户不需要重新验证。
-
啊,是的......抱歉没有完全投入大脑:-(
标签: groovy functional-testing spock geb