如何让 testcafe 复制和使用与实际网站相同的 headers?

How can I make testcafe to copy and use same headers as the actual website?

我在身份验证页面上进行 运行 testcafe 测试,当向网站发送请求时,我可以看到 testcafe 是 modifying/removing/adding headers,这阻止了我做此页面上的 2FA

一发现问题,我就尝试使用 Selenium 进行自动化,以确认这是 testcafe 问题。由于 selenium 不会创建代理来插入 js 脚本并使网站自动化,我可以使用 selenium 进行自动化,但我想使用 testcafe,因为该网站是在 react 中开发的。

        await t.typeText(this.emailInput, config.userEmail)
               .click(this.nextButton)
               .typeText(this.passwordInput, config.userPassword)
               .click(this.nextButton)
               .click(this.otpOption)
               .typeText(this.otpInput, this.token)
               .click(this.signinButton)
       }

单击下一步按钮时,我应该有 2FA 表单询问代码,但我收到一个页面说无法进行身份验证(发生错误),我看到了 BeginAuth 端点的响应代码是 222 没有任何响应而不是 200.

URL 是我用来验证的,看起来像这样:

https://login.microsoftonline.com/client uuid/oauth2/authorize?response_type=code%20id_token&response_mode=form_post&client_id=client uuid&scope=openid&x-client-Ver=4.0.0

Testcafe 团队发现这是 testcafe-hammerhead 上的错误,他们已修复并将包含在下一个版本中。

https://github.com/DevExpress/testcafe-hammerhead/issues/2052

现在我在自动化中生成 cookie 并在 header 中发送它。