c# - Selenium: Unable to access iframe and data inside it -
i have html code iframe:
<iframe class="class1" prio="0" title="details" type="detail" source="/something/somepage.aspx" style="display:none" frameborder="0"></iframe>
this frame has menu, text input , buttons inside opens popup on current page. popup gets data source page above.
i tried different approaches i.e. finding index manually of iframe , display title see if @ right frame had no luck it.
i trying type data in form in iframe , main page being clueless. please !
switchto()
method takes index, name or frame element, can try use name or frame element.
//find frame class/title/type/source iwebelement detailframe = driver.findelement(by.xpath("//iframe[@class='class1']")); driver.switchto().frame(detailframe); //alternatively, find frame first, use getattribute() frame name iwebelement detailframe = driver.findelement(by.xpath("//iframe[@class='class1']")); driver.switchto().frame(detailframe.getattribute("name")); //you in iframe "details", find elements want in frame iwebelement foo = driver.findelement(by.id("foo")); foo.click(); //switch main frame driver.switchto().defaultcontent();
Comments
Post a Comment