Resolving Protractor Test Hangs on Non-Angular Pages
Learn how to diagnose and fix Protractor test hangs on non-Angular pages using browser.waitForAngularEnabled(false) to prevent synchronization timeouts.
27 Feb 2026, 05:03 UTC

The Problem: Tests Stalling on Static Pages
When Protractor tests encounter a page that does not use AngularJS, the execution often stalls indefinitely or fails with a timeout error such as Expected condition failed. This happens because Protractor is designed to automatically synchronize with the Angular framework, waiting for the $http and $timeout services to finish their tasks before executing the next command.
On a page without AngularJS, the global angular object does not exist. Protractor continues to poll for this object and its readiness state, leading to a hang because the condition for "readiness" can never be met.
Diagnostic Matrix: Is Synchronization the Cause?
| Symptom | Likely Cause | Verification Method |
|---|---|---|
Test hangs on browser.get() or a click that leads to a new page. |
Protractor is waiting for Angular on a non-Angular page. | Check browser console for angular object. |
| Timeout error: "Angular is not ready". | Angular is present but a promise is stuck in a loop. | Check Network tab for pending API requests. |
| Intermittent failures on static HTML pages. | Race condition due to disabled synchronization. | Verify if waitForAngularEnabled(false) was called. |
Step-by-Step Diagnostic Workflow
- Confirm Page Type: Manually navigate to the URL where the test hangs. Open the Browser Developer Tools (F12) and type
window.angularin the console. If it returnsundefined, the page is non-Angular. - Verify Protractor State: Check your configuration or test setup. By default,
browser.waitForAngularEnabled()istrue. If you haven't explicitly changed it, Protractor is attempting to synchronize. - Isolate the Trigger: Determine if the hang occurs immediately after
browser.get()or after an interaction (like clicking a link to an external site).
Implementing the Fix
To stop Protractor from waiting for a framework that isn't there, you must explicitly disable Angular synchronization before the navigation occurs.
Example Configuration
Run these commands within your test spec file. This example assumes the use of async/await for promise resolution.
// Run in the test spec file
async function navigateToStaticPage() {
// 1. Disable Angular synchronization
await browser.waitForAngularEnabled(false);
// 2. Navigate to the non-Angular page
await browser.get('https://example.com/static-page.html');
// 3. Perform actions using explicit waits instead of implicit Angular sync
const element = await browser.findElement(By.id('submit-btn'));
await element.click();
// 4. Re-enable synchronization if returning to an Angular app
await browser.waitForAngularEnabled(true);
}
Operational Risks and Precautions
- Race Conditions: When
waitForAngularEnabled(false)is active, Protractor will not wait for elements to appear or for animations to finish. You must usebrowser.wait()withExpectedConditionsto ensure elements are present before interacting with them. - State Leakage: If you disable synchronization in one test and do not re-enable it, subsequent tests targeting Angular pages may fail or become flaky because they will no longer wait for the framework to stabilize.
- Deprecation Notice: Protractor is officially deprecated. While these fixes resolve immediate synchronization issues, long-term stability is better served by migrating to modern frameworks like Playwright or Cypress which do not rely on framework-specific synchronization.
Verifying the Result
To verify the fix, execute the test and monitor the Protractor logs. If the fix is successful, you will notice the following:
- The test completes the navigation and subsequent actions without the "Waiting for Angular" log entry.
- The execution time for the static page transition drops from the timeout limit (usually 30s) to a few milliseconds.
- The browser console remains clear of synchronization-related timeouts.
Rollback Procedure
If disabling synchronization causes tests to fail due to elements not being found (race conditions), revert the change by removing the browser.waitForAngularEnabled(false) call or wrapping the interaction in a browser.wait() block:
await browser.wait(ExpectedConditions.visibilityOf(element), 5000);
await element.click();0 replies
A thoughtful contribution can make all the difference. Be the first to share one.