【发布时间】: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)
【问题讨论】:
-
让我们在以下问题的上下文中讨论它:github.com/DevExpress/testcafe/issues/4296
标签: typescript authentication testing automation testcafe