Which library are you using? perhaps show an example of what you’ve tried that didn’t work and show the html (or link to the page) and you’ll get a better answer.
The approach to dealing with frames/iframes is well covered in the documentation for both libraries that drive browsers, so it’s probably related to your locators but with what you’ve given us there’s no way we can see where your problem might be.
for your first question Robot Framework 5.0 (Python 3.9.6 on win32) (Hope this is what you are asking)
Selenium Version 4.1.3
<<<"body onload=“javascript:onLoad()” onunload=“javascript:closeSession()” onresize=“javascript:onResize()” id=“home” class=“yui-skin-sam”>>>
<<<"div id=“mainContainer” style=“height: 788px;”>>>
<<<iframe name=“contentFrame” id=“contentFrame” ‘There are locators like source and border details o the frame’>>
I’ve used the code
Select Frame //*[@name=“contentFrame”]
${bln_ElmAvailable}= Run Keyword And Return Status Element Should Be Visible ${elm_ElementOnFrame}
First, watch your double quotes, I’ve been caught with them before " not ”, just double check them as that can cause issues in xpaths,
Next, maybe you’re matching another element that has the name contentFrame? I would suggest be a little more specific in your xpath, * wildcards have their place but you can be too libral with them, maybe try like this:
Select Frame //iframe[@name="contentFrame"]
Another thing that can catch you out is if you have nested iframe’s, double check your dom tree and make sure the body that this <iframe name="contentFrame" id="contentFrame" > is in is not within another frame, iframe etc. If you have nested frames then you have to select and traverse them in order, you can’t just jump to the inner frame.
Hopefully one of these will help you get your answer,
As it’s unique element on the page I used wild character. But tried both ways with and without wild characters. but no luck
I noticed the element I’m using is in nested frame but the code fails at selecting the first frame itself.
Changed code to
Select Frame //iFrame[@name=‘contentFrame’ and @id=‘contentFrame’]
Select Frame //Frame[@name=‘innerContent’ and @id=‘innerContent’]
Error : Element with locator ‘//iFrame[@name=‘contentFrame’ and @id=‘contentFrame’]’ not found.
My page have 3 Frames
Body -
a. iFrame1 start and Close
b. Div - > iFrame2 Start
c. innerFrame start (it is not iframe it is frame)
d. My element there
e.inner frame close
f. iFrame2 close
g. div close
I tried element should exist on all steps a-g all failed but all can be identified with same xpaths I’m using from devtools find bar.
In xpaths don’t use uppercase for html tags, also you usually don’t need to use @name and @id just use one, you should only use 2 tag attributes like this when it’s necessary to uniquely identify the element you want.
Also make sure contentFrame exactly matches the case it has in the html otherwise it won’t match
Can you confirm contentFrame is what you’re calling iFrame2?
Still not sure why it’s not working for you the way you have it, it seems there’s still a piece of the puzzle missing from what you’ve given, what you have should work if you’re html is as you described.
I’m still puzzled why Select Frame | //iframe[@name="contentFrame"] didn’t work for you?
Is there anything in the first iframe? did you already select that frame and click an element in there earlier in the script? if that’s the case, maybe try this:
Unselect Frame #this ensures you're at the top window not in another frame
Select Frame //iframe[@name="contentFrame"]
Select Frame //frame[@name='innerContent']