The Pros and Cons of different UI automation test tools - Puppeteer
In my previous post, we spoke about one of the most exciting newcomers to the UI automation game in Playwright. Today, I want to briefly discuss the precursor to Playwright – Puppeteer. And while it’s easy to dismiss a testing tool for a new version of it that addresses some of the tool's initial deficiencies, Puppeteer is still a solid tool in its own right and one that still deserves attention in the test automation community.
Playwright has largely been the brainchild of Microsoft, but much like Microsoft has evolved its browser technology to be based on the Chromium engine, initially developed by Google, so is it the case on the test automation front, as Puppeteer was actually created by the Google Chrome team and was first released in 2017.
Puppeteer was built on top of the Chrome DevTools Protocol, which provides a high-level API to control the Chrome browser. Like Cypress, it allows Puppeteer to interact with web pages directly rather than operate outside of the browser and be able to better manipulate the different web elements. Unlike the other testing tools, however, Puppeteer can do this in a headless format without needing to fully render the website, which saved a lot of time in execution. It does this by using its API to manipulate the status of objects and being able to determine their final result. This also allows Puppeteer to mock certain dependencies as well and provide a high level of coverage in its automation tests.
In addition to its testing capabilities, Puppeteer also quickly gained popularity for its web scraping capabilities. Developers found that they could use Puppeteer to automate the process of extracting data from websites, which saved them a significant amount of time and effort.
While most of the benefits of Puppeteer derive from its headless format it is possible to switch this off and allow for fully rendered sites should there be complex elements that may require this to verify how it looks or to get a better visual snapshot of the overall web application.
As with Selenium, Cypress, and Playwright – Puppeteer is a web-only automation framework and so interreacts outside of the browser cannot be verified. And whereas the likes of Selenium may have some drivers which can assist with things like basic Windows tasks or DB checks, Puppeteer can only do this if there is an API or command that can be initiated directly from the browser to verify this functionality.
Where Puppeteer perhaps differs the most from Playwright is that it uses an HTTP connection as opposed to a WebSocket connection, which means it is more susceptible to flakiness in dealing with asynchronous communication. And while it doesn’t run in parallel directly, it can easily do so with the use of other tools.
Recommended by LinkedIn
Pros:
Cons:
When to select Puppeteer:
This part is pretty similar to my previous post on Playwright, as the two tools share a lot of common libraries and design approaches, meaning that they will likely suit the same type of organizations.
Puppeteer is an important tool in the web automation space, whose headless functionality provides a useful benefit to many test automation engineers. Playwright might be the new toy that is getting people excited, but much like how Google’s Chrome still delivers some extra features outside of Edge’s efficiency, Puppeteer still has something to offer its Microsoft counterpart.
Programmer Analyst at Covenant Health
1yMy understanding is that Playwright came about because Google didn't want Puppeteer to be made available outside Chrome so the dev team walked.