【问题标题】:How can I make testcafe to copy and use same headers as the actual website?如何让 testcafe 复制和使用与实际网站相同的标题?
【发布时间】:2019-06-18 12:07:00
【问题描述】:

我在身份验证页面上运行 testcafe 测试,我可以看到 testcafe 在向网站发送请求时正在修改/删除/添加标头,这阻止了我在此页面上执行 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

【问题讨论】:

  • - 当我编辑并重新发送请求时,我可以获得 200 和响应正文,但我需要删除标头:x-hammerhead|xhr|request-marker: true x-hammerhead|xhr|origin: https://login.microsoftonline.com 并添加来源之一:Origin: https://login.microsoftonline.com
  • 这可能是 TestCafe 中的一个错误。我们将在github ticket 的上下文中寻找解决方案。
  • 谢谢@Artem 我忘了在这里添加评论,但是确实是一个错误,我在 testcafe 锤头 github 项目中创建了这个问题并忘记在此处添加答案

标签: header automated-tests e2e-testing web-testing testcafe


【解决方案1】:

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

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

现在我正在自动化中生成 cookie 并将其发送到标题中。

【讨论】:

    猜你喜欢
    • 2019-07-01
    • 1970-01-01
    • 2011-12-03
    • 2018-04-03
    • 1970-01-01
    • 2016-02-25
    • 2014-05-05
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多