Test Automation For Web Apps With Playwright Cd89d3e0a5
Test Automation For Web Apps With Playwright Cd89d3e0a5
Disclaimer
https://twitter.com/nicoorschel @nicoorschel@masto.ai
https://de.linkedin.com/in/nico-orschel https://mvp.microsoft.com
Nico
Orschel https://www.orschel.info https://www.xpirit.com
DevOps Whisperer,
Xpirit Germany
4
Playwright is a
Cross-browser
https://github.com/microsoft/playwright https://playwright.dev/
5
https://github.com/
microsoft/playwright
8
Why Playwright?
Source: https://www.slideshare.net/Applitools/playwright-a-new-test-automation-framework-for-the-modern-web
9
Playwright Architecture
JavaScript
Python
Java
Language Bindings
C#
Single Automation Protocol Unify all debugging protocols Common Driver API
Playwright can interact with HTML Locators are the central piece of Playwright includes test assertions in
Input elements such as text inputs, Playwright's auto-waiting and retry- the form of expect function. To make
checkboxes, radio buttons, select ability. In a nutshell, locators an assertion, call expect(value) and
options, mouse clicks, type represent a way to find element(s) choose a matcher that reflects the
characters, keys and shortcuts as on the page at any moment. expectation. There are many generic
well as upload files and focus matchers like toEqual, toContain, toB
elements. eTruthy that can be used to assert
any conditions.
11
Toolset for
Debugging Tests
Screenshots
• https://playwright.dev/docs/screenshots
Videos
• https://playwright.dev/docs/videos
Inspector
• https://playwright.dev/docs/debug#playwright-inspector
Traceviewer
• https://playwright.dev/docs/trace-viewer
• Playwright Trace Viewer is a GUI tool that helps you explore recorded
Playwright traces after the script has ran. You can open
traces locally or in your browser on trace.playwright.dev.
This Photo by Unknown Author is licensed under CC BY-SA
12
Test generator
Playwright comes with the ability to
generate tests for you as you
perform actions in the browser and
is a great way to quickly get started
with testing. Playwright will look at
your page and figure out the best
locator, prioritizing role, text and test
id locators. If the generator finds
multiple elements matching the
locator, it will improve the locator to
make it resilient that uniquely
identify the target element.
https://playwright.dev/docs/codegen
13
Sharing of browsers
Browser using isolated
BrowserContext’s is
possible and fast
BrowserContext
Each BrowserContext
has it’s own cache and
Page cookies
Playwright
Browser
Demo
16
Selenium
HTTP Over
HTTP Server
Selenium Browsers
Browsers
Client Library Driver
18
Playwright
WebSockets
All Commands
Tests Playwright
19
Request
HandShake
Web Socket
Client
VS
HTTP Connection
Request
Response
Summary
Playwright does not reinvent the wheel A good addition to the older
of end-2-end testing, but makes some frameworks
• Auto await
It still makes sense to use
• Browser Context
architecture patterns like
• Helper APIs Page Objects together with
• Debugging tools Playwright
Thank
You
22
Get in touch
Mobile: +49 173 510 1479 Mail: norschell@xpirit.com
https://twitter.com/nicoorschel @nicoorschel@masto.ai
https://de.linkedin.com/in/nico-orschel https://mvp.microsoft.com
Nico
Orschel https://www.orschel.info https://www.xpirit.com
DevOps Whisperer,
Xpirit Germany
23
Additional information
01 https://playwright.dev/ 05 https://www.programsbuzz.com/article/playwright
-architecture
02 https://www.slideshare.net/Applitools/
playwright-a-new-test-automation- 06 https://www.youtube.com/watch?v=15DcaG1EnyU
framework-for-the-modern-web
07 https://2023.boosterconf.no/program/friday/1_sho
04 https://medium.com/version- rt_talks_and_workshops/dr%C3%A6ggen_4/133-
1/playwright-vs-selenium-which-is- climbing-to-the-top-of-the-testing-pyramid-
faster-and-more-stable- with-playwright/Playwright_Booster_2023.pptx
c41ba1a89c0a#:~:text=What%20is%20Pl
aywright%3F,in%20testing%20complex%
08 https://www.lambdatest.com/playwright
20testing%20projects
24
Additional information
Democode -
09
https://github.com/norschel/Playwrigh
tDemos
10 Playwright in CI Pipelines -
https://github.com/norschel/Playwrigh
tDemos/tree/Topic/Playwright_in_CI/.
github/workflows