Effective DOM selector patterns. Interact like a user | Carter Capocaccia
Vložit
- čas přidán 22. 08. 2024
- When writing tests that interact with your UI, you will likely utilize DOM nodes to isolate elements of your application and perform actions or assertions upon those elements or contents thereof.
In this talk, Carter ranks DOM node selectors styles into three "tiers" and discusses why he favors some over others and how Cypress enables us to act like a user more than ever before. Using poor selectors is akin to building your house upon sand. You can build a mansion of a test suite using poor selectors, but the test suite will crumble violently and require constant maintenance.
Really useful best practise tips for someone like me who is also starting their baby steps with js/automation and cypress :)
writing test in this visual style.. looking for a "visible" button with a text.. has some new own "problems".. in my world.. i have to deal with 13 languages ... can you describe how to deal with that circumstances?
cy.get('button').contains('Buy') - it's kinda anti-pattern. if you want select button with text just use it like - cy.contains('button', 'Buy') with one comand without unnecessary chaining
11:07 rankings of ways to grab elements