testcafe, использующий скрипт amazon-congnito-identity-js, не работает только в IE или Edge - PullRequest
2 голосов
/ 18 июня 2019

Когда мы запускаем testcafe в IE или Edge, он прерывается (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

нпм: 5,6,0

IE: 11 Край: 17,18


Обновление

Показывать получение консольных сообщений перед входом в систему, это сообщение отображается.

IE / Край

{"log":[],"info":[],"warn":[],"error":["Error during service worker registration: SecurityError","Error during service worker registration: SecurityError"]}
* * Хром тысяча сорок-девять / 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 }
);

React 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,
      })
...