Playwright with java :
Playwright came from puppeteer dev team
PlayWright can be used to automate chromium, webkit, firefox using a single API
Linux, MACOS, WQINDOWS
Pythin, .net java
Playwright official website :
No waits required, automatic waits and synchronization
Assertions –
Tracing – capture screenshots, configure test retry strategy, eliminates flaky tests,
Pierce shadow frames, iframes
Fast execution, full isolation
Runs on a browser context mechanism
What is browser context mechanism : In playwright, browser context mechanism is like an incognito
session window which is separate for each context.
Like if we do parallel tests, in a sinle browser
Codegen : Records the actions and generates the test with any language
Open source
Session 2 : Cypress vs Playwright comparision :
Page 1 can be logged in with user 1
Page 2 can be logged in with user 2
Multi window support
Playwright architecture – Session 3 :
WebSocket protocol :
Once a connection is established bwn client and server, then we can send all the requests in the
same connection without terminating bwn.
If we close the connection, from either client side or server side, then only it will terminate.
Making the test execution faster.
Play wright Architecture :
Py.click()
This command is executed in node.js (a java script runtime env)
Then it will send the command to playwright library(API)
Then the playwright will modify these commands to low level browser language via browser protocol
(CDP)
Then the browser will perform the actions
And send the response back.
First script :
PlayWright session 6 :
Codegen inspector, playwright debugger
In order to launch the inspector, in the CLI run this command :
mvn exec:java -e -D exec.mainClass=com.microsoft.playwright.CLI -D exec.args="codegen
https://www.marvell.com/"
And then click enter, and then the codegen inspector gets launched and u can record ur actions and
the code gets generated in all the languages and u can copy that to ur class file
Debugging :
In order to debug, run as configurations, there add variable as :
PWDEB , value as 1 and click on apply
Now the playwright inspector will run and then the debug is running, u can stop near every step and
run and then check.
And in this stage as well u can do the record and play.
This is an amazing feature of playwright.
Session 7 :
Playwright tracing :
Locators :
Text locators :
Page.locate(“text=Sneha”)
Session 11 : Frames , iframes :
Whenever we are entering into an iframe, then all the elements present inside has to be referred
using that iframe only.
Else how the page will know inside which iframe, the element has to be searched for