当我们在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上发生。
你能帮我吗?
环境
testcafe:1.2.1
节点:8.11.3
npm:5.6.0
IE:11 边缘:17,18
显示登录前获取控制台消息,这是显示消息。
IE / Edge
{"log":[],"info":[],"warn":[],"error":["Error during service worker registration: SecurityError","Error during service worker registration: SecurityError"]}
Chrome / Safari / firefox
{"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 }
);
反应src
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,
})