0

几天以来我一直有这个问题。我开始使用 testcafe,但无法正确登录。这是我的第一个测试:

const role = Role('https://mywebsite.com', async t => {
    await t.typeText(authenticationPage.loginInputBox, user.login)
    .typeText(authenticationPage.passwordInputBox, user.password)
    .click(authenticationPage.signInButton);
}, { preserveUrl: true });

export default async () => {
    await navigate_as();
};

async function navigate_as() {
    await t
        .setTestSpeed(0.1)
        .useRole(role)
        .navigateTo("https://mywebsite.com/#/dashboard");
    await t
        .click(portfolioPage.navigateAs)
        .typeText(portfolioPage.navigateAsInput, "John Doe")
.expect(portfolioPage.navigateAsAutocomplete.exists).notOk({timeout: 10000});
}

问题是服务器通常会重定向到仪表板,但是使用 testcafe 在第一次登录重定向到仪表板后,它会在这里停留 1 秒并重定向到错误页面。它说 502 bad gateway 如下所示(因此之后测试崩溃):

在此处输入图像描述

有没有人遇到这个问题并且可以告诉我发生了什么?我可以通过 testcafe 配置来解决这个问题吗?我正在使用最新版本的节点(v10.4.1)并尝试使用 IE、Firefox 和 Chrome,结果与 tescafe(v0.18.6)(Windows 7 操作系统)相同

不使用角色的代码如下,它给出了相同的结果:

async function sign_in_with_sso() {
    await t
            .setTestSpeed(1)
            .typeText(authenticationPage.loginInputBox, user.login)
            .typeText(authenticationPage.passwordInputBox, user.password)
            .click(authenticationPage.signInButton)
            .expect(authenticationPage.formIsLoading.exists).notOk({timeout: 10000});
}

谢谢,

4

0 回答 0