Python,Selenium-即使在切换之后也无法在IFRAME中找到元素

Python,Selenium-即使在切换之后也无法在IFRAME中找到元素,python,selenium,iframe,Python,Selenium,Iframe,我试图从iframe中的输入字段中获取值。我切换到iframe,但程序仍然无法找到元素,因此引发超时异常。我正在使用internet explorer web驱动程序,无法使用任何其他驱动程序,因为该网站仅在internet explorer中工作 我使用的代码是: browser = webdriver.Ie() browser.get('http://www.thewebsite.com') wait = WebDriverWait(browser, 10) wait.until(EC.fr

我试图从iframe中的输入字段中获取值。我切换到iframe,但程序仍然无法找到元素,因此引发超时异常。我正在使用internet explorer web驱动程序,无法使用任何其他驱动程序,因为该网站仅在internet explorer中工作

我使用的代码是:

browser = webdriver.Ie()
browser.get('http://www.thewebsite.com')
wait = WebDriverWait(browser, 10)
wait.until(EC.frame_to_be_available_and_switch_to_it((By.ID, 'Content')))
MRR = wait.until(EC.element_to_be_clickable((By.XPATH, "//INPUT[@id='txtTotalMonthlyCharge']"))).get_attribute('value')
我已经试着增加等待时间,并通过ID定位

HTML:

<iframe id="Content">
<html>
    <head>

    </head>
    <body style="margin-left: 0; margin-top: 0; overflow:hidden">
        <form name="frmServicesTree" method="post" action="ServicesTree.aspx?AccountNo=50084779&amp;pageID=SERVICESTREE" id="frmServicesTree">
    <table>
    <tr>
        <td class="flowLabel" width="140px"><span id="txtTotalMonthlyChargelabel" style="width:95%;height:17px;">Total Monthly Charge</span></td><td class="flowReadOnly"><input name="txtTotalMonthlyCharge" id="txtTotalMonthlyCharge" type="text" readonly="" tabindex="-1" value="JA$11,199.00" style="vertical-align:top;width:100%;" /></td>
    </tr>
    </table> 
    </body>
</iframe>

每月总费用

是否可能是案例问题?您是否尝试过“//input…”?在您的代码示例中,您正在按ID切换到
iframe
,但您发布的HTML示例中的
iframe
没有ID。这是故意的吗?@Christine它有一个想法。我只是不小心在示例中遗漏了它,我的朋友,您是否检查过IFRAME是否嵌套了?