How to select a frame with no name or id in robot framework?

learning_dev_me picture learning_dev_me · Nov 13, 2015 · Viewed 8.2k times · Source

I need to select a frame but it has no name or id. How do it do it?

<frame src="sampleSrouce" scrolling="yes" frameborder="0" />
<frame src="sampleSource2" scrolling="yes" frameborder="0" />

Thanks!

Answer

Atishay picture Atishay · Nov 24, 2015

We can get the xpath count, and then get the attribute value of src.

If we get the desired src value we can pick the counter value and create an xpath with index.

Then we can use Select frame with the xpath to select the value.

${count}=    Get Matching Xpath Count    .//div[@dir]/iframe

   :FOR    ${i}    IN RANGE    1    ${count}+1
    \    ${myText}=    Selenium2Library.Get Element Attribute    xpath=//iframe[${i}]@src
    Exit For Loop
Select Frame    xpath=//iframe[2]
Selenium2Library.Input Text    id=text1    test