【问题标题】:Testcafe & microsoft authentication fails to redirect during authentication flowTestcafe & microsoft 身份验证在身份验证流程中无法重定向
【发布时间】:2019-09-18 10:57:26
【问题描述】:

所以我正在为我们的 Web 应用程序编写 Testcafe 的测试脚本,并熟悉 typescript。我所做的基本上是有一个 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)
    };
};

正在加载PageTests.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)

【问题讨论】:

标签: typescript authentication testing automation testcafe


【解决方案1】:

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

【讨论】:

    猜你喜欢
    • 2019-09-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-05-01
    • 1970-01-01
    • 2012-01-25
    • 2017-09-09
    • 1970-01-01
    相关资源
    最近更新 更多