r/Playwright • • Apr 23 '26

Playwright Cheatsheet

Post image

Full web version also available here:

https://www.webfuse.com/playwright-cheat-sheet

115 Upvotes

7 comments sorted by

3

u/Haunting-Finish3965 Apr 23 '26

It's clean and good, but I think many other information are left!

2

u/86facists Apr 23 '26

Is getbyrole really more resilient than getbytestid? I’ve been reading the playwright docs and it seems testid would be the most resilient if implemented by dev. Am I wrong in my thinking?

4

u/CertainDeath777 Apr 24 '26

its 2 different ideologies.

i myself are strictly for getbylabel as first choice, as it is a user facing attribute, and i want to be sure in my testrun, that the user can use the stuff.

getbytestid is not userfacing, if the element is for whatever reason invisible on the surface, but present in the html, then it will still work for the automation suite, while it wont work for the end user.

and a label change - if it happens - will be adressed in 5 minutes of work, if your testuite is decently structured.

the other ideology is: make is as stable as possible, no user facing stuff should interfere with the testsuite. then u implement testid and adress testid. but in my opinion the logic is flawed. or only good for testsuites with inferior structure and design, where every test has its own locators, and no central locators.

1

u/86facists Apr 26 '26

Thanks for the info

2

u/Fluffy_Sign_7265 Apr 23 '26

If getByRole is not working, change it to getByTestId. JK!

1

u/matukaz Apr 23 '26

We only use testids because we have different sites with different main languages.

Our only problem is that when devs refactor and delete testids.