Question
ExpectedConditions on Angular 2+ apps: Is Protractor’s sync reliable?
Zo Lane
0 reputation · 01 Mar 2024, 06:30 UTC
85.6K views0
Goal
Developers want to use Protractor’s ExpectedConditions to wait for elements in an Angular 2+ application. The assumption is that the condition will only resolve when the Angular framework has finished rendering the target element.
Constraints & Uncertainty
- Protractor’s automatic synchronization via
$browser.waitForAngular()relies on AngularJS digest hooks that are absent in Angular 2+ (Ivy). - When
browser.waitForAngularEnabled(true)is used, tests often hang or fail to locate elements on Angular 2+ pages. - Disabling sync with
browser.waitForAngularEnabled(false)allows ExpectedConditions to work, but requires manual management and can introduce flakiness if the flag is not toggled correctly between tests.
Unresolved Decision
Should Protractor maintain a separate synchronization path for Angular 2+ applications, or should it continue to rely on the developer to manually disable sync and manage waits?
Specific Questions
- When using
ExpectedConditionson an Angular 2+ page, does the condition guarantee that the page has finished rendering the target element, or does it only check the element’s current state? - Would a dedicated Angular 2+ synchronization mechanism in Protractor improve test stability, or is manual wait management sufficient?
- What is the best practice for toggling
waitForAngularEnabledacross a test suite that includes both AngularJS and Angular 2+ pages to avoid cross‑test flakiness?