A Brief & Quick Tutorial On Playwright Testing Tool – DevstringxAnkush Chaudhary
Tutorial On 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.
Playwright Automation Framework
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.
Features 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:- List of Web Automation Testing Tools
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.
This is the GitHub Actions workflow. It builds and runs your tests from the GitHub platform.
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:
- The 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.
Contact Us to Hire Dedicated Software Test Engineers for Your Project Success!
Recommended to Read:-