Forget about ignoreSynchronization
!!! It no longer exists in protractor starting from protractor 5.3.0
browser.waitForAngularEnabled(false)
should be used instead
Step by step instructions how to use it
Protractor has builtin handling of waiting for angular and this is what makes it different. However, if the page is not angular protractor will hang until it hits timeout error, so you need to disable that feature in order to test non-angular page. There is also an edge case, when the page is angular, but this feature will STILL make protractor error out. Perform the steps below, to find out when to disable protractor's waiting for angular
- Find out if your page is Angular: open dev console in the browser and inside of 'console' tab run command
getAllAngularTestabilities()
If the output is getAllAngularTestabilities is not defined
, then your page is not angular, go to the last step to disable built-in waiting
- Run these commands in the console
getAllAngularTestabilities()[0]._ngZone.hasPendingMacrotasks
getAllAngularTestabilities()[0]._ngZone.hasPendingMicrotasks
If any of these return true
(if there are micro or macro tasks pending), then go to the last step. If all are false
, congrats, you can use the builtin protractor's waiting for angular. But if you don't like it as I don't, then read the last step to find out how to disable it
- Run the above mentioned command. BUT! It returns a promise, which needs to be handled, preferably using
await
keyword
await browser.waitForAngularEnabled(false)
This command can be ran anywhere: in the it
block, in beforeAll
, or in onPrepare
of your configuration. Just make sure, if you use await
to make the respective block async
beforeAll(async () => await browser.waitForAngularEnabled(false))
by.id
changed toBy.id
? – Percent