How to work with iframes

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

*** Settings ***
Documentation     Working with forms inside and outside of an iframe.
Library           RPA.Browser

*** Tasks ***
Input text in form field inside an iframe, then outside the iframe
    Open Available Browser
    Wait Until Element Is Visible    __privateStripeFrame5
    Select Frame    __privateStripeFrame5
    Input Text When Element Is Visible    name:cardnumber    4242424242424242
    Unselect Frame
    Input Text    name    Robot

The Select Frame keyword (from the RPA.Browser 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.

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