Protractor Alternatives for Angular E2E Testing
The calculator for this page is switched off while it is checked. The formula is below, and the worked example in the article shows how to use it by hand.
Protractor, the long-standing end-to-end (E2E) testing tool for Angular, was officially deprecated in 2022 and is no longer maintained. This article explains the main alternatives—Cypress, Playwright, WebdriverIO, and TestCafe—and how to choose one for your Angular project. Each tool has different strengths, so the right choice depends on your team’s familiarity, testing style, and CI environment.
Why Protractor Was Deprecated
Protractor was built on top of Selenium WebDriver and Angular-specific APIs like element and by. For years it was the default for Angular E2E tests because it could automatically wait for Angular’s change detection to settle. However, Angular’s team announced in 2020 that Protractor would be deprecated, and the final release came in 2022. The main reasons were the rise of more modern testing frameworks, the maintenance burden of keeping up with Selenium changes, and the shift toward tools that offer better debugging and speed.
Key Alternatives Overview
- Cypress – A developer-friendly framework that runs in the browser, with time-travel debugging and automatic waiting.
- Playwright – A cross-browser automation library by Microsoft, known for speed, reliability, and multi-tab support.
- WebdriverIO – A Selenium-based tool that integrates well with the existing WebDriver ecosystem and supports both sync and async modes.
- TestCafe – A Node.js tool that does not use WebDriver, offering simple setup and parallel test execution.
Comparing the Main Tools
Cypress is often praised for its interactive test runner and clear error messages. It runs inside the browser, which gives it a unique architecture that avoids many flakiness issues. However, it does not support multiple browser tabs or iframes as naturally as Playwright does. Playwright, on the other hand, offers a more complete automation API, including mobile emulation, network interception, and parallel execution across browsers. WebdriverIO is a good choice if you already have Selenium infrastructure and want to keep using it. TestCafe is easy to set up and does not require browser drivers, but it has a smaller community and fewer integrations.
How to Migrate from Protractor
Migrating from Protractor to a new tool is not a one-to-one translation. You will need to rewrite your test code because the APIs and the way you locate elements differ. Here are the general steps:
- Choose a target framework (e.g., Playwright or Cypress) based on your team’s needs.
- Set up the new framework in your project and install the necessary dependencies.
- Replace Protractor-specific selectors like
by.modelandby.bindingwith standard CSS or XPath selectors that work with the new tool. - Update your waits. Protractor’s automatic waiting for Angular is not present in other tools; you will need to use explicit waits or the tool’s built-in auto-waiting features.
- Refactor your page objects to match the new API (e.g.,
cy.get()in Cypress orpage.locator()in Playwright). - Run and debug incrementally, starting with the most critical user flows.
Common Challenges and Solutions
One common challenge is handling Angular’s asynchronous operations. In Protractor, you could use browser.waitForAngular() to wait for the app to settle. In Cypress, you can use cy.intercept() to wait for network requests, or use cy.wait(0) as a hack, but it’s better to use explicit assertions. Playwright has built-in auto-waiting that waits for elements to be actionable, which handles most cases. Another challenge is dealing with Angular Material components, which often have complex DOM structures. You may need to use more specific selectors or data-testid attributes to make tests robust.
How to Choose the Right Tool
There is no single best tool; it depends on your project’s context. Consider the following factors:
- Team familiarity – If your team already knows JavaScript and Cypress, it may be quicker to adopt. If they have Selenium experience, WebdriverIO might be easier.
- Testing needs – Do you need to test in multiple browsers? Playwright supports Chrome, Firefox, Safari, and Edge. Cypress supports Chrome, Firefox, and Edge, but Safari support is limited.
- Debugging experience – Cypress’s time-travel debugging is excellent, while Playwright offers a trace viewer that records screenshots and network requests.
- CI/CD integration – All tools work with common CI systems, but Playwright has a built-in test runner that simplifies parallel execution.
- Community and support – Cypress and Playwright have large communities and active development. WebdriverIO has a solid community but is less popular now.
Cost and Licensing
All the main alternatives are open-source and free to use. Cypress has a paid cloud service for recording and analytics, but the core framework is free. Playwright is fully open-source, and the test runner is free. WebdriverIO and TestCafe are also free. You only need to pay for additional services like CI minutes or cloud browsers if you use them.
Frequently Asked Questions
Is Cypress better than Playwright for Angular?
It depends on your needs. Cypress is easier to get started with and has a more intuitive API, but Playwright offers better cross-browser support and more advanced features like network interception and mobile emulation. For Angular specifically, both work well, but you need to disable the Angular-specific waiting and use standard selectors.
Can I use Protractor alternatives with AngularJS (version 1)?
Yes, but with caveats. Cypress and Playwright can test AngularJS apps, but they do not have built-in support for AngularJS’s digest cycle. You may need to add explicit waits or use the angular global to check if the app is stable. WebdriverIO also works, but you lose the automatic waiting that Protractor provided.
Do I need to rewrite all my tests when migrating?
Yes, most likely. The APIs are different, and you will need to update selectors and waits. However, the logic of your test scenarios can be reused. It’s a good opportunity to refactor and improve your test suite.
What is the best way to handle Angular Material components in Playwright?
Use data-testid attributes on the components you want to interact with. Playwright’s locators can target these attributes easily. For example, page.getByTestId('submit-button'). This makes your tests less brittle than relying on CSS classes or XPath.
Are there any tools that automatically convert Protractor tests?
There are some community scripts and tools, but none are fully automatic. They can help with basic syntax, but you will still need to manually adjust selectors and waits. It’s usually faster to rewrite tests manually, especially if you have a small suite.
Related
Formula used
Each line is one input (in, sel, list) or one result (out: label, unit, formula, decimals). How the calculators work
Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.