Is there a reason why the first line of code works and the second one doesn't? I have also attached what the webpage looks like.
self.page.locator("[data-test="BundleGroup"]").get_by_role("checkbox").first.check()
self.page.locator("[data-test="BundleGroup"]").get_by_role("checkbox").filter(has_text='Estoppel Certificate').first.check()
This thread is trying to answer question "Why is playwright not detecting elements?"
Locators are strict by default and will return nothing if several elements match
with 1.34, you may use "and" condition, see https://playwright.dev/python/docs/release-notes#version-134
Example New locator.and_() to create a locator that matches both locators.
button = page.get_by_role("button").and_(page.get_by_title("Subscribe"))
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].