Playwright is an awesome new browser automation library. With Playwright, you can automate web UI interactions for testing or for web scraping with a concise, uniform API in one of four languages: Python, C#, Java, and JavaScript. Playwright is also completely open source and backed by Microsoft. It’s a powerful alternative to Selenium WebDriver.
On December 1, 2021, I delivered a workshop on Playwright for TAU: The Homecoming. In my workshop, I taught how to build a test automation project in Python using Playwright with pytest, Python’s most popular test framework. We automated a test case together for performing a DuckDuckGo web search.
If you missed the workshop, no worries: You can still take the workshop as a self-guided tutorial! The workshop instructions and example code are located in this GitHub repository:
https://github.com/AutomationPanda/tau-playwright-workshop
To take the workshop as a self-guided tutorial, read the repository’s README, and then follow the instructions in the Markdown guides under the workshop folder. The workshop has five main parts:
- Getting started
- What is Playwright?
- Our web search test
- Test project setup
- First steps with Playwright
- Browsers, contexts, and pages
- Navigating to a web page
- Performing a search
- Writing assertions
- Checking the search field
- Checking the result links
- Checking the title
- Refactoring using page objects
- The search page
- The result page
- Page object fixtures
- Nifty Playwright tricks
- Testing different browsers
- Capturing screenshots and videos
- Running tests in parallel
If you get stuck or have any questions, please open issues against the GitHub repository, and I’ll try to help. Happy coding!
One comment