Я изменил свои тесты на async / await, и с тех пор browser.getCurrentUrl () работает нормально, за исключением этого теста:
(Filling out a Form)
...
await element(by.id('auftrag-disponieren')).click();
await browser.wait(EC.visibilityOf($('list')), 1000).catch((e) => {
console.log(e);
});
since('How it should be, but is #{actual}').
expect(await browser.getCurrentUrl()).toContain("https://someRandomDomain.com");
})
});
выдает следующее предупреждение, но все равно проходит тест:
>(node:13760) UnhandledPromiseRejectionWarning: Error: Error while waiting for Protractor to sync with the page: "both angularJS testability and angular testability are undefined. This could be either because this is a non-angular page or because your test involves client-side navigation, which can interfere with Protractor's bootstrapping. See http://git.io/v4gXM for details"
at runWaitForAngularScript.then (C:\Users\mat\AppData\Roaming\npm\node_modules\protractor\built\browser.js:463:23)
at process._tickCallback (internal/process/next_tick.js:68:7)
(node:13760) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:13760) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
(node:13760) UnhandledPromiseRejectionWarning: Error: Error while waiting for Protractor to sync with the page: "both angularJS testability and angular testability are undefined. This could be either because this is a non-angular page or because your test involves client-side navigation, which can interfere with Protractor's bootstrapping. See http://git.io/v4gXM for details"
at runWaitForAngularScript.then (C:\Users\mat\AppData\Roaming\npm\node_modules\protractor\built\browser.js:463:23)
at process._tickCallback (internal/process/next_tick.js:68:7)
(node:13760) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2)
Если я попаду адреса текущей перед кодом клика Это безуспешны, ̶ Šo подмигнули не из-за ̶r̶e̶d̶i̶r̶e̶c̶t̶.̶ ОТКЛЮЧЕНИЯ Try-Catch BLOCK ВОКРУГ НЕГО ̶w̶o̶n̶'̶t̶ HELP ̶e̶i̶t̶h̶e̶r̶.̶ ̶
Я использую browser.getCurrentUrl()
несколько раз в разных тестах, но это единственное, где я получаю это предупреждение.
Изменить:
Отключение функции since()
и попытка await expect(..).toContain(..)
не помогли. Я получил тот же результат, что и раньше.
Возможно, мне следовало упомянуть, что у меня есть следующая функция
afterAll(async () => {
await browser.get("https://someRandomDomain.com/dashboard")
})
Edit2:
Я думаю, что предупреждения происходят от функции afterAll(async () => {await browser.get("https://someRandomDomain.com/dashboard")})
. С момента комментирования этой строки я не получаю эти предупреждения. Но все же я использую эту функцию в различных тестах, и они не будут выдавать эти предупреждения.