Reputation: 1
I am working on selenium from java code. In my current page there are two frames and i basically want to search for a text in any of these two frames in the page.
Now, the problem is when i reach to this page, the focus doesn't seem to be coming on the newly opened page and therefore to the frames in it.
I tried following few options: 1. Selenium.SelectFrame("relative=top"), index=0/1, SelectFrame("//frame"); 2. Tried selenium.getEval("document.getElementsByTagName('frame')[0].contentWindow.document"); 3. Also tried selenium.selectWindow() with name/title options.
I am still not able to get the focus on the current page and therefore not able to search for the intended text ( i am using selenium.isTextPresent("text") ) for this but it is not working because i guess focus it not shifting to the frame/page.
Could you please let me know what am i missing ?
Thanks, Suman
Upvotes: 0
Views: 1268
Reputation: 9569
Selenium can't search across multiple frames. If you want to look for the same string in either frame, you have to code two searches. For example:
main.html:
<html>
<frameset>
<frame id="frame1" src="frame1.html">
<frame id="frame2" src="frame2.jhtml">
</frameset>
<html>
frame1.html:
<html>
<body>
<p>Hello from frame 1!</p>
</body>
<html>
frame2.html:
<html>
<body>
<p>Hello from frame 2!</p>
</body>
<html>
Then the following should find "Hello" in either frame:
foundHello = false;
selenium.selectFrame("relative=top");
selenium.selectFrame("id=frame1");
if selenium.isTextPresent("Hello") then foundHello = true;
selenium.selectFrame("relative=top");
selenium.selectFrame("id=frame2");
if selenium.isTextPresent("Hello") then foundHello = true;
if (foundHello) then ... blah blah blah ...
Upvotes: 1