Search code examples
robotframeworkselenium2library

How to Automate Iframe Text flied Using Robotframework


Here it is

enter image description here

HTML Code

<iframe id="sq-card-number" name="sq-card-number" class="sq-input" frameborder="0" width="100%" scrolling="no" height="18" src="https://pci-connect.squareup.com/v2/iframe?type=cardNumber&amp;app_id=sandbox-sq0idp-tVvPe-svMrqgtzNNRvmStg" allowpaymentrequest="true"></iframe>

Below Thing is Script,And Get fails for Input Text Keyword

* TestCases *

Select Frame    xpath=//iframe[contains(@id,'sq-card-number')]

Input Text  id=sq-card-number   Iframe

Solution

  • You do not differ two different element IDs - you need to select the iframe content first (Select Frame) and then you have to wait for your textbox to appear within the iframe - and wait for this. Unfortunately this is not stated above so: find your text input ID and make sure you replace it in the code example below.

        Wait Until Page Contains    id=sq-card-number
        Select Frame    id=sq-card-number
        Wait Until Page Contains Element    id=myTextFieldElement
        Wait Until Element Is Visible    id=myTextFieldElement
        Input Text    id=myTextFieldElement   Iframe