如何在运行testcafe测试时避免编写浏览器cookie?

问题描述 投票:1回答:2

我正在为一个网站运行testcafe测试。我想在运行testcafe测试时避免编写任何浏览器cookie。我的网站写了cookie,但在运行测试时我想避免这种情况。有没有办法在testcafe中实现这一目标?

cookies automated-tests e2e-testing web-testing testcafe
2个回答
2
投票

如果您想在测试开始时没有cookie,请注意TestCafe会在每次测试开始前自动清除cookie。

如果要在测试场景的某个时刻清除cookie,则可以使用Role,例如,如果要作为其他用户进行身份验证。

如果您的场景更复杂,请查看RequestMockRequestHook - 它们允许您在测试会话期间控制所有请求和响应的任何方面。


2
投票

要在Google Chrome浏览器中停用Cookie,请按以下步骤操作:

  • 在Google Chrome个人资料中找到“偏好设置”文件,并将2指定为profile.default_content_settings.cookies键值。
  • 在浏览器别名后指定:userProfile标志。
testcafe 'chrome:userProfile' /tests
© www.soinside.com 2019 - 2024. All rights reserved.