第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

如何使用 Python 在 iframe 中切換 Selenium 焦點(diǎn)

如何使用 Python 在 iframe 中切換 Selenium 焦點(diǎn)

暮色呼如 2023-02-22 16:27:16
我無(wú)法從網(wǎng)站上的下拉菜單中選擇復(fù)選框。下拉菜單位于 iframe 內(nèi),當(dāng)我嘗試切換到 iframe 時(shí),我不斷收到TimeoutException消息:。下面是我正在嘗試的代碼和 HTML。我是 Python 的新手,所以對(duì)此的任何幫助將不勝感激。Python:wait = WebDriverWait(driver, 20)frm1= wait.until(EC.presence_of_element_located((By.ID, "ReportViewerControl_ctl04_ctl03_ctl01")))driver.switch_to.frame(frm1)HTML:<iframe id="ReportViewerControl_ctl04_ctl03_ctl01" onclick="event.cancelBubble=true;" onactivate="event.cancelBubble=true;" style="display: block; position: absolute; z-index: 10; left: 208px; top: 35px; width: 198px; height: 166px;" src="javascript:'';" frameborder="0" title="Area place holder" longdesc="Area place holder" name="ReportViewerControl_ctl04_ctl03_ctl01"></iframe>
查看完整描述

1 回答

?
楊__羊羊

TA貢獻(xiàn)1943條經(jīng)驗(yàn) 獲得超7個(gè)贊

要在而不是中切換Selenium的焦點(diǎn),您必須:<iframe>presence_of_element_located()

  • 誘導(dǎo)WebDriverWait以等待所需的框架可用并切換到它。

  • 您可以使用以下任一定位器策略

    • 使用CSS_SELECTOR

      WebDriverWait(driver, 10).until(EC.frame_to_be_available_and_switch_to_it((By.CSS_SELECTOR,"iframe[name^='ReportViewerControl'][longdesc='Area place holder']")))
    • 使用XPATH

      WebDriverWait(driver, 10).until(EC.frame_to_be_available_and_switch_to_it((By.XPATH,"//iframe[starts-with(@id, 'ReportViewerControl') and @title='Area place holder']")))
    • 注意:您必須添加以下導(dǎo)入:

      from selenium.webdriver.support.ui import WebDriverWait
      from selenium.webdriver.common.by import By
      from selenium.webdriver.support import expected_conditions as EC


查看完整回答
反對(duì) 回復(fù) 2023-02-22
  • 1 回答
  • 0 關(guān)注
  • 164 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)