Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to traverse through different frames inside an iFrame?

I have a iframe given below, I can traverse to iframe, but can't perform any operations like traverse or click on other components or frames inside the frameset. How do I click the frames/elements inside the frameset?

<iframe id="selector_window" name="selector_window" src="/webadmin/webeditor/selectormanager_wcm.jsp? width="750" height="450">
<html><head>
<meta http-equiv="pragma" content="no-cache">
</head>
<frameset rows="*,100" border="1" bordercolor="Gray">
    <frameset cols="200,200,200" border="1" bordercolor="Gray">
        <frame name="selectorlistfilter" src="blank.html" frameborder="1">
        <frame name="selectorlist" src="blank.html" frameborder="1">
        <frame name="selectorpreview" src="blank.html" frameborder="1">
    </frameset>
    <frame name="selectorinsert" src="blank.html" marginwidth="2" marginheight="2" frameborder="0">
</frameset>
</html>
</iframe>         
like image 355
Juhan Avatar asked Mar 19 '23 11:03

Juhan


2 Answers

switch to any frame element , just use driver.switchTo().frame("framename");

Once we switched to one frame, if we need to switch to another frame, we have to switch to the parent frame.For that use

driver.switchTo().parentFrame();

If you use driver.switchTo().defaultContent();, it may not work. so go for driver.switchTo().parentFrame();, it works fine.

like image 161
Juhan Avatar answered Mar 21 '23 01:03

Juhan


In selenium always follow the sequence. From parent->child1->child2 and again 
Webdriver parent = driver.switchTo().frame(0);
Webdriver child1 = driver.switchTo().frame(1);
Webdriver child2= driver.switchTo().frame(2);
going back to parent 

driver.switchTo().frame(1)
driver.switchTo().defaultcontent();
like image 33
amogh Avatar answered Mar 20 '23 23:03

amogh