I have a <div class data-test-id="left-bar">...
and inside are multiple menu items (inside multiple <span>), I'd like to put them in an array / object then do assertion, what's the cleanest way to do that?
e.g.
const navMenu = ['Home', 'Favourites', 'Login', 'Help']
// do an assertion serially
This thread is trying to answer question "What is the cleanest way to put multiple menu items inside <span> in an array or object and then do an assertion?"
const links = page.$$(selector) , this will store the link in an array and then you can expect(links).tobe(['Home', 'Favourites', 'Login', 'Help'])
https://playwright.dev/docs/api/class-elementhandle#element-handle-query-selector-all
Rayrun is a community for QA engineers. I am constantly looking for new ways to add value to people learning Playwright and other browser automation frameworks. If you have feedback, email [email protected].