Я использую Selenium в Python для автоматизации некоторых задач на веб-странице. На веб-странице есть несколько вложенных iFrames, и мне нужно углубиться в четвертый вложенный iFrame, чтобы нажать на кнопку. первые три вложенных iFrame могут быть быстро переключены на, но когда дело доходит до четвертого iFrame, я всегда получаю ошибку тайм-аута, даже если я установил время ожидания до 120 с. Ниже приведен код Python и HTML. iframe name = "portalDisplay"> - это третий вложенный iframe, а iframe name = "ECMCOs" - это тот, на который я хочу переключиться и нажмите кнопку внутри него. Спасибо!
browser.switch_to_default_content()
WebDriverWait(browser, 60).until(EC.frame_to_be_available_and_switch_to_it((By.XPATH,'//iframe[@id="content"]')))
WebDriverWait(browser, 60).until(EC.frame_to_be_available_and_switch_to_it((By.XPATH,'//div[@id="unique1"]/iframe[1]')))
WebDriverWait(browser, 60).until(EC.frame_to_be_available_and_switch_to_it((By.XPATH,'//div[@id="divPageBody"]/iframe[1]')))
WebDriverWait(browser, 120).until(EC.frame_to_be_available_and_switch_to_it((By.XPATH,'.//iframe[@name="ECMCOs"]')))
<iframe name="portalDisplay" src="emxPortalDisplay.jsp?portal=ECMEnterpriseChangeMgtPortal&header=EnterpriseChangeMgt.Label.ECMChangeCOsCAsLeagcySummaryPageHeading&emxSuiteDirectory=enterprisechangemgt&treeLabel=91852699+001&suiteKey=EnterpriseChangeMgt&StringResourceFileId=emxEnterpriseChangeMgtStringResource&SuiteDirectory=enterprisechangemgt&objectId=20336.41905.42762.46685" width="100%" height="100%" frameborder="0" border="0" cd_frame_id_="ca6315bf2f2783f6030dd845f480d61d">
#document
<html>
<head>..<head>
<body>
<!-- //XSSOK -->
<script language="javascript" src="/enovia/common/scripts/emxUICore.js"></script>
<!-- //XSSOK -->
<script language="javascript" src="/enovia/common/scripts/emxUIModal.js"></script>
<script language="Javascript">
</script>
<script language="JavaScript"> var DisplayErrorMsg = "";
</script>
<div class="pv-container" id="divPowerView" data-portalname="ECMEnterpriseChangeMgtPortal" style="overflow-y: hidden;">
<div class="pv-row" id="divPvRow-1" minsize="240" style="height: 709px;">
<div class="pv-channel complex" id="divPvChannel-1-1" style="width: 100%;
float: right; height: 100%;">
<div class="pv-channel-tabs" id="pvChannelTabs">
<table cellpadding="0" cellspacing="0" border="0">
....
</div>
<div class="pv-channel-content" style="">
<div class="tab-header" style="display: none;"></div>
<iframe name="ECMCOs" src="../common/emxIndentedTable.jsp?
sortColumnName=Name&PrinterFriendly=true&SuiteDirectory=enterprisechangemgt&treeLabel=91852699+001&parentOID=20336.41905.42762.46685&emxSuiteDirectory=enterprisechangemgt&HelpMarker=emxhelpchangeordersection&program=enoECMChangeUtil%3AgetConnectedChanges&functionality=isChangeOrderTab&portalMode=true&StringResourceFileId=emxEnterpriseChangeMgtStringResource&toolbar=ECMChangeOrderManagementToolbar&sortDirection=ascending&selection=multiple&portalCmdName=ECMCOs&jsTreeID=null&suiteKey=EnterpriseChangeMgt&header=EnterpriseChangeMgt.Label.ECMChangeCOsCAsLeagcySummaryPageHeading&portal=ECMEnterpriseChangeMgtPortal&table=ECMChangeSummary&objectId=20336.41905.42762.46685" frameborder="0" width="100%"></iframe></div>
<div class="pv-channel-content" style="display: none;">
<div class="tab-header" style="display: none;"></div><iframe name="ECMCRs" src="" frameborder="0" width="100%"></iframe></div><div class="pv-channel-content" style="display: none;"><div class="tab-header" style="display: none;"></div><iframe name="ECMChangeLegacy" src="" frameborder="0" width="100%"></iframe></div></div></div></div></body></html>
Фрагмент TML enter code here
: