A Brief & Quick Tutorial On Playwright Testing Tool
What Is Playwright Tool?
Playwright launches a headless browser by default. The command line is the only way to use the headless browser as it doesn’t show any user interface.
Why Use Playwright Web Automation?
Playwright is an open-source platform developed by Microsoft. It is relatively new to the market but has quickly gained popularity. Microsoft constantly updates and improves it based on user feedback.
Developed by the Microsoft team, Playwright is a comprehensive testing and automation platform that is slowly gaining popularity. Not only is it versatile and easy to use, but it also offers blazing-fast execution speeds and outstanding features that only the Playwright framework offers, such as Trace Viewer and Test Generator.
Trace Viewer and Test Generator
- Trace Viewer is a GUI tool to view Playwright traces after testing. If you want to experiment with this, you can set “tracking” to “enabled” in your playwright.config.js:
After the tests are completed, Trace.zip files are generated in the test results folder.
- Test Generator is a browser tool provided by Playwright that records actions performed in the browser and generates corresponding code. This is useful when you want to quickly prepare for some tests or to improve the skills of team members who are new to coding.
Feature of Playwright Testing Framework
Here are some unique features of Playwright’s Testing Framework:-
- The platform supports cross-browser development in Chromium, WebKit, and Firefox, including Chrome, Edge, Firefox, Opera, and Safari.
- Windows, Linux, and macOS are supported Cross-platform execution.
- Automatic waits, smart assertions that retry until an item is found, and data tracking tests — track logs and videos easily.
- Developed with modern architecture and without limitations, the application allows you to interact with multi-page, multi-tab websites like a real user and easily manage frames and browser events.
- Since the Playwright platform is adapted to a modern browser architecture, testing is not limited during the process.
Good to Read:- Most Popular Test Automation Tool Recommended By Experts
Folder Structure of Playwright Framework
After Installing the Playwright NPM package from the command line, you’ll have a similar project structure as the VS Code extension workflow.
- playwright.yml: This is the GitHub Actions workflow. It builds and runs your tests from the GitHub platform.
- tests/example.spec.js: This is a sample spec file generated during Playwright initialization.
Advantages of Playwright
It also has many advantages for test automation.
- It supports multi-tab, multi-user, and iframe test cases.
- It is available as a VS Code extension with one-click-to-run tests and includes step-by-step debugging, selector exploration, and logging of new tests.
- Generate an HTML report to view the results of the test run in the browser.
- It supports different types of testing, such as end-to-end, functional, and API testing.
- Supports automated accessibility testing with third-party plugins.
- It provides various debugging options like Playwright Inspector, Browser Developer Tools, VSCode Debugger, and Monitor Viewer Console Logs.
- It has inbuild reporters like JSON, JUnit, and HTML Reporter. You can also create custom reports using Playwright
Disadvantages of the Playwright
Here are some disadvantages of the Playwright test:
- Playwright does not support Microsoft Edge or earlier IE11.
- The playwright uses a desktop browser instead of a real device to emulate a mobile device
- Although Playwright supports API auditing, its APIRequest method does not support disabling tracking redirects.
Recommended to Read:-
- Tutorial On Taiko A Free & Open Source Browser Automation Tool
- Introduction of WinAppDriver Free Test Automation Tool
- Top Fast & Easy Manual Testing Tools
Originally published at https://www.devstringx.com on March 20, 2023