5

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!

learning_dev_me
  • 269
  • 2
  • 3
  • 9
  • 2
    Is there a reason not to set the ID in there by yourself? `` – Pepelius Nov 13 '15 at 08:41
  • 1
    Have you tried crafting an xpath that looks for a frame element that has a `src` attribute with the value `"sampleSrouce"? – Bryan Oakley Nov 13 '15 at 12:01
  • @ProDexorite This is already an existing application in Production. Therefore, adding an id just for automated testing is unlikely to happen. – learning_dev_me Nov 13 '15 at 23:11
  • 1
    @BryanOakley that is a good suggestion. However, just realized that is not a good solution here since the "src" produced is not fixed. It is changed depending on the page. Is there any similar approach just like in selenium webdriver wherein I can use driver.switchTo().frame(1)? – learning_dev_me Nov 14 '15 at 00:33

2 Answers2

3

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
Atishay
  • 197
  • 1
  • 2
  • 10
2

So basically, I found out that the solution is quite simple. I just used an xpath that points to the second frame:

xpath=/html/frameset/frame[2]

learning_dev_me
  • 269
  • 2
  • 3
  • 9