Click in Element Inside Iframe Document Using Playwright/Python
Question:
How can I click on this element that is inside an iframe with an html document?
Answers:
Since Playwright version 1.17, there is a special page.frameLocator
in Playwright for iFrame. This should allow you to access the elements within the iFrame without any problems.
Here is a sample code for the correct syntax:
const btn = page.frame_locator("your-iframe").locator("text=Your Text");
await btn.click();
You need now adapt the example to your HTML structure. Hope it helps you. More details for python usage: https://playwright.dev/python/docs/api/class-framelocator
Here’s the Python version of the sample code.
https://playwright.dev/python/docs/api/class-framelocator
locator = page.frame_locator("my-frame").locator("text=Submit")
locator.click()
See this example that clicks on a captcha inside an iframe:
frame = page.frame_locator(Captcha_Iframe).locator(Captcha_Checkbox)
await frame.click(timeout=10000)
How can I click on this element that is inside an iframe with an html document?
Since Playwright version 1.17, there is a special page.frameLocator
in Playwright for iFrame. This should allow you to access the elements within the iFrame without any problems.
Here is a sample code for the correct syntax:
const btn = page.frame_locator("your-iframe").locator("text=Your Text");
await btn.click();
You need now adapt the example to your HTML structure. Hope it helps you. More details for python usage: https://playwright.dev/python/docs/api/class-framelocator
Here’s the Python version of the sample code.
https://playwright.dev/python/docs/api/class-framelocator
locator = page.frame_locator("my-frame").locator("text=Submit")
locator.click()
See this example that clicks on a captcha inside an iframe:
frame = page.frame_locator(Captcha_Iframe).locator(Captcha_Checkbox)
await frame.click(timeout=10000)