在Geb测试中关闭和打开浏览器的正确方法是什么?

时间:2013-08-22 15:34:05

标签: groovy functional-testing spock geb

我使用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,因为这就是这个测试验证的内容。

1 个答案:

答案 0 :(得分:0)

添加您的测试,以保存会话Cookie。

autoClearCookies = false

link

相关问题