← 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

const links = page.$$(selector) , this will store the link in an array and then you can expect(links).tobe(['Home', 'Favourites', 'Login', 'Help'])


Related Discord Threads

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 luc@ray.run.