Reputation: 479
While trying to run example spec with a small change in the script as below and getting below error. It looks like before performing assertion in if block it's changing URL to google and then checking the assertion on google page.
import {browser, element, by, By, $, $$, ExpectedConditions} from 'protractor';
describe('async function', function() {
it('should wait on async function in conditional', async function(): Promise<any> {
await browser.get('http://www.angularjs.org');
const todoList = element.all(by.repeater('todo in todoList.todos'));
if ((await todoList.count()) > 1) {
expect((await todoList.get(1).getText())).toEqual('build an AngularJS app');
}
await browser.get('http://www.google.com');
});
});
Error:
[10:58:03] E/protractor - Could not find Angular on page http://www.google.com/ : retries looking for angular exceeded
async function
✗ should wait on async function in conditional
- Failed: Angular could not be found on the page http://www.google.com/.If this is not an Angular application, you may need to turn off waiting for Angular.
Please see
https://github.com/angular/protractor/blob/master/docs/timeouts.md#waiting-for-angular-on-page-load
Please see
https://github.com/angular/protractor/blob/master/docs/timeouts.md#waiting-for-angular-on-page-load
at executeAsyncScript_.then (/node_modules/protractor/lib/browser.ts:936:29)
Upvotes: 0
Views: 244
Reputation: 42304
Each of the pages that you make a GET
request to with browser.get
needs to be running AngularJS. Google doesn't run AngularJS, so your request fails. The first request (to www.angularjs.org
works, because they themselves run AngularJS, and therefor Protractor is able to run on that page.
As the error message says, "If this is not an Angular application, you may need to turn off waiting for Angular". You can tell Protractor that the target page is not an Angular application by running browser.waitForAngularEnabled(false)
before browser.get
, although remember that you'll probably want to turn it back on at a later stage!
Hope this helps! :)
Upvotes: 2