Disabling Protractor's Angular Synchronization for Non-Angular Pages
How to stop Protractor from hanging on jQuery widgets and external iframes by turning off automatic Angular waits, and what to replace them with.
19 Jul 2025, 02:53 UTC

The hanging test on a hybrid page
You inherit a Protractor suite for an AngularJS application. Most views behave, but one page embeds a legacy jQuery datepicker and an external payment iframe. When the test clicks into that section, Protractor pauses. It does not fail immediately; it waits until the default timeout expires. The reason is automatic Angular synchronization.
Protractor automatically pauses before every action until Angular reports that it has no pending $http requests, $timeout callbacks, or active zone-based change detection cycles. On a page where Angular never bootstraps—or where a non-Angular widget controls the DOM—that stability signal may never arrive.
What the toggle actually does
browser.waitForAngularEnabled(false) tells Protractor to skip the Angular stability check before the next action, or for the rest of the session if called in onPrepare. It does not turn off WebDriver itself; elements can still be located and clicked. It simply removes the implicit wait for Angular.
Angular-specific locators such as by.model, by.binding, and by.repeater depend on that synchronization. With it disabled, those locators will fail or time out because Protractor cannot query Angular's internal bindings.
Worked example: toggle around a legacy widget
Run the spec from your project root in a terminal. No special permissions are required, but the Protractor Selenium server must be reachable at the address in your configuration file.
// specs/hybrid-page_spec.js
describe('Hybrid Angular and jQuery page', () => {
beforeEach(async () => {
await browser.get('/legacy-widgets');
});
it('opens a jQuery datepicker without waiting for Angular', async () => {
// Disable synchronization because this section is not Angular-managed.
await browser.waitForAngularEnabled(false);
await $('#legacy-datepicker').click();
await $('.ui-datepicker-calendar a.ui-state-default').first().click();
// Re-enable before returning to Angular views.
await browser.waitForAngularEnabled(true);
});
});
Expected check: the datepicker click should proceed immediately instead of hanging until the Protractor timeout. Risk: once synchronization is off, Protractor will not wait for the datepicker calendar to render. Add an explicit WebDriver wait, such as browser.wait(ExpectedConditions.visibilityOf(...), 5000), or the test may click a missing element.
Diagnostic: confirm Angular is really absent
Before disabling synchronization, open the page in a browser and run this in DevTools:
console.log(window.angular);
If the result is undefined, Angular is not bootstrapped on that page, and automatic synchronization has nothing to wait for. If window.angular exists but the page still hangs, a pending $http request or zone task may be stuck, which is another reason to disable synchronization temporarily.
Trade-offs and limitations
- No automatic waits: disabling synchronization means every DOM change after a click or navigation needs an explicit
browser.waitorExpectedConditionscall. - Angular locators break:
by.model,by.binding, andby.repeaterrequire Angular and will not work on non-Angular sections. - Deprecated tool: the Angular team has deprecated Protractor and does not promise new features or security patches. Treat this as a short-term stabilization for existing suites, not a long-term investment.
Rollback and closing
Because this changes test behavior, rollback is simple: remove the waitForAngularEnabled(false) calls or change false to true, then re-run the suite to confirm the previous behavior.
Use the toggle only for the specific non-Angular sections that need it, re-enable it immediately afterward, and add explicit waits where Angular no longer watches the DOM. If you are starting a new project, choose a maintained framework such as Playwright, WebdriverIO, or Cypress instead of Protractor.
0 replies
A thoughtful contribution can make all the difference. Be the first to share one.