【发布时间】:2019-04-18 18:40:39
【问题描述】:
我正在为一个网站运行 testcafe 测试。我想避免在运行我的 testcafe 测试时编写任何浏览器 cookie。我的网站会写入 cookie,但在运行测试时我想避免这种情况。有什么办法可以在 testcafe 中实现这一点?
【问题讨论】:
标签: cookies automated-tests e2e-testing web-testing testcafe
我正在为一个网站运行 testcafe 测试。我想避免在运行我的 testcafe 测试时编写任何浏览器 cookie。我的网站会写入 cookie,但在运行测试时我想避免这种情况。有什么办法可以在 testcafe 中实现这一点?
【问题讨论】:
标签: cookies automated-tests e2e-testing web-testing testcafe
要在 Google Chrome 浏览器中禁用 cookie,请按以下步骤操作:
2 指定为 profile.default_content_settings.cookies 键值。 testcafe 'chrome:userProfile' /tests
【讨论】:
如果您希望在测试开始时不使用 cookie,请注意 TestCafe 在每次测试开始之前会自动清除 cookie。
如果您想在测试场景的某个时刻清除 cookie,例如,如果您想以不同的用户身份进行身份验证,您可以使用 Role。
如果您的场景更复杂,请查看 RequestMock 和 RequestHook - 它们允许您在测试会话期间控制所有请求和响应的任何方面。
【讨论】: