← Back to Discord Forum

Best Approach to only click button?

everythingeasyposted in #help-playwright
Open in Discord

is this good approach to click the tab only if it's visible?

rules_tab = self.page.get_by_role("tab", name="Rules")

or is there any other best way to do it?

This thread is trying to answer question "Is it a good approach to use an 'expect' function to ensure a tab is visible before clicking it, or is there a better way?"

1 reply

Hi, the expect is not needed. The click itself will only succeed if the tab is visible (or becomes visible within the action timeout), see: https://playwright.dev/python/docs/actionability

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.