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

标签 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,因为这是此测试要验证的内容。

最佳答案

在您的测试中添加,用于保存 session cookie。

autoClearCookies = false

link

关于groovy - 在 Geb 测试中关闭和打开浏览器的正确方法是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18384924/

相关文章:

testing - 什么是复杂 Web 应用程序功能测试的最佳工具

testing - Linux设备驱动程序功能测试

jquery - 如何使用 jQuery 与 Spock/Geb 一起选择第二个 Class 元素

groovy - 我如何从文本文件中读取并打印值

reflection - Groovy:如何获取在基类中声明的属性

groovy - Camunda 无法执行 groovy 脚本

testing - 软件测试建议?

grails - grails生成的 Controller 测试在子类上失败

unit-testing - Grails-Spock : while projecting values in query id doesn't exist

java - mockito-groovy-支持不工作