Search code examples
seleniumxpathrobotframeworkselenium2library

How to find if web element is invisible or executed through Javascript


I am trying to input some text into text field using the following robotframework code and web element is not getting selected.Can someone suggest/guide me how this can achieved or how to identify if web element is invisible or executed through Javascript .Following is the example that I have tried.

*** Settings ***
Library          Selenium2Library
Suite Teardown   close all browsers

*** Test Cases ***
Example using custom selenium keyword
    Open browser   https://10.12.60.110:21412/logon.jsp  browser=chrome
    Input Text       //input[@id='_id0:logon:USERNAME']      Administrator
    Input Text       //input[@id='_id0:logon:PASSWORD']      Welcome1

I have tried using execute JAVAscript command in robot framework Selenium2Library.

Export CSV from SAP BO
    Open browser   https://10.12.60.200:8443/BOE/BI    browser=chrome
    Execute Javascript      document.getElementById('_id0:logon:USERNAME').value='Administrator' ; 
    Execute Javascript      document.getElementById('_id0:logon:PASSWORD').value='Admin1' ; 
    Click Button       LOGIN

I have tried using xpath and element is not getting selected using xpath.

<input id="_id0:logon:USERNAME" name="_id0:logon:USERNAME" type="text">

xpath is //input[@id='_id0:logon:USERNAME'] but output is no matching nodes.PFA screenshot below enter image description here

enter image description here


Solution

  • The issue looks like coming from the fact the login is in an iframe - look at your first screenshot, the document starts with html > body > frame. So switching to it should make the rest of yoyr sample code work:

    Select Frame     a_locator_for_that_iframe