Unable to locate iframe in Selenium Webdriver(java)
automation, iframe, java, selenium-webdriver, testing
Solution
You can switch to a frame by its index . Try the following:
//go to popup
//switch to the first frame , assuming there's only one frame with no id or name
driver.switchTo().frame(0);
driver.findElement(By.name("hier_data_id")).click();
Problem
I want to select a element of iframe which is located with in a popup window. I am able go inside popup window but not able to locate iframe. Below is html code of popup window. ``` <html> <head></head> <body> <iframe width="100%" height="100%" border="0" src="/some/url.do?parameter=getData"> <html> . . <table id="ec_table" class="tableRegion" width="20%" cellspacing="1" cellpadding="2" border="0"> <tr class="even"> <td> <input type="radio" value="173" name="hier_data_id"> </td> </tr> . . </html> </iframe> </body> </html> ``` Here I want to click Radio button which is located inside iframe. I used below code to switch with in iframe but it is not switching to iframe. ``` driver.switchTo().frame(myD.findElement(By.tag("iframe"))); ``` As iframe doesn't have id, i'm finding difficulty locate elements inside iframe. Does anyone know how I could do it..? Thanks in advance.