Unable to find iframe in selenium webdriver (Java)

I want to select an iframe element in the pop - up window I can enter the pop-up window, but I can't find iframe The following is the HTML code of the pop-up 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 the radio button located in iframe I used the following code to switch in iframe, but it didn't switch to iframe

driver.switchTo().frame(myD.findElement(By.tag("iframe")));

Since iframe has no ID, I find it difficult to find elements in iframe

Who knows what I do?

Thank you in advance

Solution

You can switch to the frame through the 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();
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>