automated-tests - 使用 amazon-congnito-identity-js 脚本的 testcafe 仅在 IE 或 Edge 上失败
问题描述
当我们在 IE 或 Edge 上运行 testcafe 时,它中止了。(Chrome/Safari/Firefox 工作正常)我们使用 amazon-congnito-identity-js 进行身份验证。
testcafe 命令
testcafe --live edge tests/* --screenshots my-fixture/edge
testcafe --live ie tests/* --screenshots my-fixture/ie
这是中止代码的一部分。
await t
.click('#login')
.wait(1000);
中止消息
1) - Error in Role initializer -
An error occurred in the native dialog handler called for a native alert dialog on page
所以我们像这样设置一个 setNativeDialogHandler 。
await t
.setNativeDialogHandler((type, text, url) => {
throw 'alert was revoked: ' + text;
})
.click('#login')
.wait(1000);
对话文本是这样的。
NotAuthorizedException: Incorrect username or password.
此消息可能从 AWS cognito 返回...
但是用户名和密码设置正确。
cognitoUser.authenticateUser(
console.log("user is " + username);
console.log("password is " + password);
new AuthenticationDetails({
Username: username,
Password: password,
}), {
onSuccess: success,
onFailure: failure,
})
console.log(在调试模式下)
username is test // <- correct
password is 12345678 // <- correct
此错误仅发生在 IE 或 Edge 上。
你能帮助我吗?
环境
测试咖啡馆:1.2.1
节点:8.11.3
npm:5.6.0
即:11 边缘:17,18
更新
登录前显示获取控制台消息,这是显示的消息。
IE/边缘
{"log":[],"info":[],"warn":[],"error":["Error during service worker registration: SecurityError","Error during service worker registration: SecurityError"]}
铬/Safari/火狐
{"log":[],"info":[],"warn":[],"error":[]}
export const regularAccUser = Role(URL, async (t: TestController) => {
await t
.typeText(id, 'test')
.typeText(pass, '12345678 ');
const message = await t.getBrowserConsoleMessages();
console.log(JSON.stringify(message));
await t
.click('#login')
.setNativeDialogHandler((type, text, url) => {
throw 'alert was revoked: ' + text;
})
.wait(1000);
}, { preserveUrl: true }
);
反应源
import {
CognitoUserPool,
AuthenticationDetails,
CognitoUser,
} from 'amazon-cognito-identity-js';
var cognitoUser = new CognitoUser({
Username: username,
Pool: userPool(),
});
console.log("user is " + username);
console.log("password is " + password);
cognitoUser.authenticateUser(
new AuthenticationDetails({
Username: username,
Password: password,
}), {
onSuccess: success,
onFailure: failure,
})
解决方案
推荐阅读
- c# - system.http 中的“没有这样的主机是已知的”将端点打到 Web api
- php - CakePHP 3.6.14:在弹出窗口中打开视图 -> 在 null 上调用成员函数 url()
- swift - Swift / firebase / firebase中的儿童数量增加
- css - 多个css @media(最大宽度:)不起作用
- python-3.x - python区分大小写禁用并获取eual字符串
- authentication - 使用 oidc 的 JWT 使用不同数量的客户端进行身份验证
- python - 如何使用 selenium python 在 facebook 上单击“添加朋友”按钮
- javascript - 响应式导航栏(移动设备问题)
- regex - HTML 模式正则表达式字符之间至少有一个空格
- java - 在大数据(数千行和列)的情况下,为每个单元格设置 CellStyle()