'Playwright Python Click in element inside iframe document

How can I click on this element that is inside an iframe with an html document?

IMAGE

.click() does not work



Solution 1:[1]

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

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1