← Back to Discord Forum

Assert option to be visible

hello guys!

Is there a way to check, when i click on the select, if options inside a select become visible? If yes, does it make sense to do this check? Or is it enough to check that the text inside the options is the one expected?

This thread is trying to answer question "How can I verify that options inside a select element are visible after clicking the select, and is it necessary to perform this check?"

3 replies

Yes it is possible and for the second question the answer is: it depends. Remember that testing is also subject to tradeoffs, so you don't want to test something that is not critical and has a negligible impact on code correctness if writing that test is more likely to cause problems than benefits. Moreover e2e tests are not very reliable, regardless of the effort the Cypress, Playwright, Nightwatch etc teams put in their respective projects to make them work flawlessly. If I was in you I'd do this test as a unit or integration test using your frontend frameworks testing tools.

Yes it is possible Have you tried already?

Because i tried with a classic expect:

await this.page.locator("#select_id").click() await expect(this.page.locator("#select_id option")).toBeVisible()

But it doesn't work..

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.