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>
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.
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();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With