Just a year back Cypress was the leader in the market and gained a lot of popularity due to its unique features. but Cypress trade-offs and other promised features did not work in an expected for many users. As expected modern users are not ready to go back to selenium they were expecting alternative solutions. However, there was no strong competitor to Cypress somehow users get adjusted to Cypress.
But today the Playwright has arrived as a strong competitor to Cypress though the Playwright did initial release in 2020 it has come up with a lot of features and overcome almost all tradeoffs that Cypress had. So Playwright is trending now and looks like it's the future automation framework.
What users did not like in Cypress?
iFrame Restrictions: Cypress might be well suited for the modern applications, but there is a lot of organization still using hybrid model, where they were looking for a single framework for their organization, as we know maintaining multiple frameworks inside the organization is difficult. Cypress doesn’t support iFrame completely and achieving this would be challenging.
Cross-Origin/Third Party Login Issues: Cypress told its own reason for not to automate third party login scenarios, but for end to end testing it matters a lot, Cypress suggests to third party login should be through API's, etc. but we have come across the cases where the organization has to modify their login just for test automation and integrate Cypress inside their organization. Test Automation is part of testing and many organization doesn’t want invest on their resources and effort customize their login process to integrate Cypress.
If you are using a third-party login solution like SSO or any Identity management solution, managing those through automation is a challenging task, as Cypress doesn’t allow Cross-Origin domains in the same script.
Multiple Window/Tab Support: Again Cypress doesn’t support Multiple window or Tab, Cypress gave a workaround for this, remove the target attribute. As a tester, one would like to replicate the same scenario just like end-users do, but this somehow feels like a hack, Many users are not convinced.
Browser Support: Cypress still figuring out how to support Safari Browser, There are a lot of Mac users using Safari, Testers want to run tests on all browsers and we should not be limited to a few sets of browsers.
Parallel Browser Testing: If you are testing locally you can run only one instance of the browser with Cypress, Parallel browser testing is restricted by Cypress. Many users don’t want to spend their time executing tests one after another.
Page Object Pattern: Page Object Pattern is practiced by many organizations and testing tools, however, Cypress did not encourage that, though we can achieve Page Object Pattern with some customizations. Cypress came up with App Actions instead of Page Objects
Edge Case Sceanrios: Many users are stuck with edge case scenarios like file upload, download scenarios, For everything, we cannot rely on third-party plugins which are not a good idea as well from organization perspective.
CI/CD Integration Problems: If Organization is using third-party hosted agents, you need to install Cypress first dynamically for each run, Installation time sometime crossed 10 to 15 mins which, If your organization is paying for build agents on a time basis, you might end up paying extra for doing installation of Cypress.
Async/Await Issues: Using Async/Await inside your Cypress makes Cypress tests behave in a weird way, which was not expected by modern frameworks.
Test Grouping and Test Suites: Who doesn’t want to create Test Suites, Those who want to migrate from the protractor were looking for something similar feature like the protractor has, however, Cypress has been in the market for many years and did not think of this simple feature.
XPath: Cypress Supports locators in a good way, but for XPath again you need to rely on plugins.
Dependency: If you are using Cypress, you end up adding more and more third-party plugins as many features are not supported by Cypress Natively, which many users did not like. User is not sure long third-party plugins are supported, and managing their version up-gradation as Cypress releases new version is a difficult job.
Debugging: Cypress removed directly debug support from Visual Studio Code, you need to rely on developer tools, and its own debugger. Some users liked it but some did not.
Automatic waits: Cypress document says, it waits for elements to load before performing any actions, but there are many scenarios it did not work as expected
When it comes to end-to-end testing or Test Automation, many users looked for similar features like Selenium, but Cypress did not meet all their expectations.
Cypress was the leader back then, they would have concentrated more on git hub issues instead of suggesting workarounds and third-party plugins, which many users did not like.
Now, the time has changed users got an easy alternative, Playwright has arrived.
The playwright is aggressive in terms of delivering new features, Within a year it has evolved a lot, and now it looks like matured framework. The playwright is open source however it’s managed by Microsoft.
Why People are liking Playwright?
No iFrame Restrictions: Unlike Cypress, Playwright doesn’t restrict you in terms of iFrame, it allows you to do any actions with iFrame
No More Cross-Origin Restrictions: Unlike Cypress, Playwright doesn’t ask you to stick to a single domain, it’s like you got browser instances wherever you navigate you can, and automate them.
Browser Support: Currently Playwright Supports Chromium, Firefox, and Web toolkit (Safari)
Parallel Execution Support: Playwright supports parallel execution of tests
Xpath Support: No need to install additional plugins for Xpath, Playwright has ready for you when you install Playwright Package.
Visual Studio Code debugging: You can configure your Playwright Framework with Visual Studio Code and debug them inside, and developer tools as well.
CI/CD Integration: CI/CD integration is just like any other testing framework it runs smoothly there as well.
Automatic waits: Playwright has an inbuilt automatic wait mechanism and it provides custom wait options as well.
Multi-Window Support: Playwright allows you to work with multiple tabs/windows and get control over them
Upload and Download Files: Playwright provides many options to control the file upload and download, you no longer need to install third-party plugins into your framework.
Page Object Model: Playwright supports page object patterns directly, it has even documentation on how to achieve those, which is nice.
Unique Features of Playwright
The above features of Playwrights are discussed in comparison with Cypress, apart from those Playwright has unqiue features, which we rarely find in modern automation frameworks
CodeGen: You can record your tests with Playwright Code Gen, When you start with CodeGen it will generate a tests script for you.
Testing Safari on Windows: When you install Playwright Framework, it will also install a set of browsers like chrome, Firefox, Webkit, etc. The Webkit browser is an open-source version of Safari, You can run the Webkit browser on windows machine, which means you are testing Safari features on windows machine.
Emulate devices: You can emulate devices and run your tests just by using single command with Playwright.
Generate PDF : You can generate PDF using Playwright, This is a unique feature compared to another framework.
Test Retries: You can specify the number of restries for your tests, this is common feature though, playwright is also providing.
Allure Report: Playwright is providing Allure Report Integration feature as well which many are looking for.
Rather than restricting, Playwright is giving more features to users, which stands Playwright as unique framework. The playwright is aggressively delivering features and fixing issues, so we cannot stop expecting more features.
Should I Choose Playwright over Cypress?
Many users ask this question, however only you and your organization can get an answer for this, we don’t know about your application, we don’t know your requirement, we can only list our pros and cons. For some Cypress looks Better than Playwright, For some Playwright. You need to find the best fit through analysis.
Note: Opinion expressed in this article is the in-person view and it is limited to knowledge. I am trying to compare two frameworks' features and limitations, This article is not sponsored and I am neither associated with Cypress nor with Playwright, the article is intended to help the community. Opinions might vary from person to person. Nothing is perfect in this world everything in this universe has its own pros and cons.