What is Puppeteer?
Google launched puppeteer in 2017. Puppeteer is a powerful library which provides an API to control headless Chrome or Chromium over the DevTools Protocol.
What can it do?
Puppeteer can be used for automating all the manual or GUI interactions. When it comes to debugging, this tool becomes any developer's choice.
How does it work?
Why choose Puppeteer?
- Puppeteer requires zero setup. Comes with chromium version making it very easy to start with.
- It has event-driven architecture which removes potential flakiness. So, there’s no need to add unnecessary wait and sleep times.
- Puppeteer runs headless by default which makes it super fast.
- Puppeteer v1.5.0 also exposes browser contexts, making it possible to efficiently parallelize test execution.
- Run in a Docker container or serverless environment.
- Intercept network requests.
- Dev tools can be used to capture performance info and can run commands in the console.
- Test a Chrome extension.
- Analyze JS bundle using the analyzer available.
- Emulate mobile viewports.
- Speed: Puppeteer has almost zero performance overhead over an automated page.
- Security: Puppeteer operates off-process with respect to Chromium, making it safe to automate potentially malicious pages.
- Stability: Puppeteer should not be flaky and should not leak memory.
- Simplicity: Puppeteer provides a high-level API that’s easy to use, understand, and debug.
How it can be used for test automation?
Using Puppeteer you can launch web pages, make UI navigations, take screenshots and generate pdf's. Pupetteer can be used with testing framework such as Jest, Mocha or make your own test framework too! It works well with Chai assertion library.
What ways this tool could help your team?
Puppeteer is the go-to tool for automation if speed and performance of automated tests are more important than portability and compatibility.
Summary
- Puppeteer works seamlessly with single-page applications.
- It creates an up-to-date, automated testing environment by directly in the latest version of Chrome using the latest JavaScript and browser features.
- Supports FireFox(beta).
- Supports parallel execution.
- Crawl a SPA (Single-Page Application) and generate pre-rendered content (i.e. "SSR" (Server-Side Rendering)).
- Capture a timeline trace of your site to help diagnose performance issues.
- If you are looking for Speed, stability, security and simple tool, then puppeteer is the best choice.
Puppeteer does not support the following
- Cross browser compatibility testing
- Does not support licensed formats such as AAC or H.264 media formats
- Puppeteer does not support HTTP Live Streaming (HLS).
- Does not support multiple languages, supports only JavaScript.
More details about test frame work and tests:
Jest framework - https://github.com/sdkdeepa/pptr-testframework
Mocha-chai - https://github.com/sdkdeepa/pptr-mocha.
Top comments (0)