How to work with iframes

Working with forms inside and outside of an iframe.


One does not simply input text into an iframe. ๐Ÿ‘Œ

The following robot navigates to the Stripe Payments Demo page and enters data into two form fields. What's interesting about the form is that one of the fields (Card) is inside an iframe element. The other field (Name) is on the page outside the iframe:

Stripe Payments Demo

Selenium (RPA.Browser.Selenium)

The Select Frame keyword (from the RPA.Browser.Selenium library) selects the iframe using its name as the locator. After entering the value into the field inside the iframe, the Unselect Frame keyword is used to move the focus back to the main window. After that, it is possible to input text into the fields outside the iframe.

Playwright (Browser)

Here is the same logic implemented with the Playwright-based Browser library:

Read A new option for web automation: Using the Robot Framework Browser library, based on Playwright for more information on how to install and use the Browser library.

There you have it: Moving in and out of an iframe!