DISHA MUNSHI
DISHA MUNSHI

Reputation: 73

Finding elements inside an iframe without a iframe id using robot framework

HTML Looks like this

<iframe src="/apex/cscfga__ConfigureProduct?linkedId=a0W8E000000Lpa5UAC&amp;configId=a0Z8E000000NBGMUA4&amp;retURL=/a0W8E000000Lpa5UAC&amp;isdtp=vw" width="100%" height="100%" onload="hideLoading()" frameborder="0" style="height: 737px;"></iframe>

Select frame doesnt work without id.How should my robot script recognise this iframe(without id)?

My script looks like

${Iframe}=  Execute Javascript  
window.document.getElementsByTagName('iframe')[2]
log ${Iframe}   

But it returns 'None'

Please suggest how do I identify this iframe.

Upvotes: 2

Views: 16125

Answers (1)

Bryan Oakley
Bryan Oakley

Reputation: 386342

Select Frame will work with any type of locator. For example, if it's the only iframe on the page you can do this:

select frame    xpath=//iframe

If there are multiple iframes on the page, you need to try to find an ancestor that is uniquely identifiable and then look for the frame relative to that.

For example, given the following html:

<div class="spreadsheet_container">
    <div>
         <iframe ...>

... you can use an xpath such as the following:

select frame    xpath=//div[@class='spreadsheet_container']/div/iframe

Upvotes: 10

Related Questions