Rayrun
← Back to Discord Forum

How to check texts inside multiple <span> sequentially in a navigation bar

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?"

1 reply
daniel_boone1990
daniel_boone1990

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

Related Discord Threads

TwitterGitHubLinkedIn
AboutQuestionsDiscord ForumBrowser ExtensionTagsQA Jobs

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].