Playwright · Junior · Question 58 of 75

How do you click a button inside an <iframe>?

Show the answer

Correct answer: page.frameLocator('#pay').getByRole('button')

Explanation

An iframe has its own document. frameLocator (or locator(...).contentFrame()) scopes locators to it.

Further reading

Problem with a question

Playwright · Junior · question 58

Test yourself

Take the Playwright · Junior quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz