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

时间:2019-09-18 10:57:26

标签: typescript authentication testing automation testcafe

因此,我正在为Web应用程序编写Testcafe的测试脚本,并熟悉打字稿。我要做的基本上是拥有一个LoginPage.ts,一个LandingPage.ts(与该问题无关)和一个LandingPageTests.ts(其中包含实际测试)。

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

我问了一个开发人员这件事,他说访问令牌已经在流程中交换了,这很奇怪。他再也不能帮助我。

昨天和今天我在Google上搜索了很多,但是有关此主题的话题已经关闭或不适合我的方法。

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

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)

1 个答案:

答案 0 :(得分:0)

像这样运行脚本,即可运行:node --max-http-header-size=1024000 ./node_modules/testcafe/bin/testcafe.js chrome <your script