Testcafe 和 Microsoft 身份验证在身份验证流程中无法重定向

Testcafe & microsoft authentication fails to redirect during authentication flow

所以我正在为我们的 Web 应用程序编写 Testcafe 的测试脚本,并熟悉打字稿。我所做的基本上是 LoginPage.ts、LandingPage.ts(与此问题无关)和 LandingPageTests.ts(包含实际测试)。

该应用程序具有使用 Microsoft 登录的身份验证流程。因此,脚本单击此应用程序中的 Microsoft 登录按钮,使用我的电子邮件填写表格,然后在组织页面上输入密码,单击“是”以在 Microsoft 登录页面中保持登录状态,然后重定向https://login.microsoftonline.com/kmsi?sso_reload=true 应该发生,但重定向目标拒绝此操作,错误代码为 500(显示在开发工具中)。

我问过开发者,他说access token已经在流程中交换了,很奇怪。他不能再帮助我了。

我昨天和今天在谷歌上搜索了很多,但关于这个的话题不是关闭就是不适合我的方法。

任何人都可以指出正确的方向,如何更改脚本以使重定向发生?我不是 testcafe 或 typescript 方面的专家。在相关文件下方,敏感数据已被删除。我不知道是什么,如果有的话,我做错了,也许我选错了职业。 :(

LoginPage.ts:

import { Selector, t } from 'testcafe';

export default class LoginPage {
    private microsoftButton = Selector('span').withText('MICROSOFT');
    private emailField = Selector('#i0116');
    private nextBtn = Selector('#idSIButton9');
    private passwordField = Selector('#passwordInput');
    private signInBtn = Selector('#submitButton');
    private staySignedIn = Selector('#idSIButton9');


    async login (username : string, password : string){
        await t
            .setTestSpeed(1)
            .click(this.microsoftButton)
            .maximizeWindow()
            .typeText(this.emailField, username, {paste : true})
            .click(this.nextBtn)
            .typeText(this.passwordField, password)
            .click(this.signInBtn)
            .click(this.staySignedIn)
    };
};

LoadingPageTests.ts:

import LoginPage from './pages/LoginPage';
import LandingPage from './pages/LandingPage';

const loginPage = new LoginPage();
const landingPage = new LandingPage();
const username = 'removed';
const password = 'removed';


fixture`removed Landing page`
  .page`removed`
  .beforeEach(async (t) => {
    await loginPage.login(username, password)

  })
  .afterEach(async (t) => {
    await landingPage.logout()
  });

test(not really relevant as the login part fails)

运行 这样的脚本并且有效:node --max-http-header-size=1024000 ./node_modules/testcafe/bin/testcafe.js chrome <your script