我在構建搜索、購買 ID 和類以及查詢中嘗試過 xpath 和 CSS 選擇器,但無法單擊“全部展開”按鈕。
按鈕
網站鏈接:https : //etherscan.io/token/0x2b591e99afe9f32eaa6214f7b7629768c40eeb39#readContract
<div class="d-flex justify-content-between mb-3">
<p class="ml-1 mr-3 mb-1">
<i class="far fa-file-alt text-secondary mr-1"></i> Read Contract Information</p>
<span>
<a href="#" class="mr-1 expandCollapseAllButton" onclick="expandCollapseAll()">[Expand all]</a>
使用的定位器:find_element_by_id
find_element_by_xpath
find_element_by_partial_link_text
find_element_by_tag_name
find_element_by_class_name
uj5u.com熱心網友回復:
該Expand all按鈕位于Iframe. 需要Switch to iframe進行點擊操作。最好應用一些等待:
# Imports Required:
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
driver.get("https://etherscan.io/token/0x2b591e99afe9f32eaa6214f7b7629768c40eeb39#readContract")
wait = WebDriverWait(driver,30)
frame = wait.until(EC.frame_to_be_available_and_switch_to_it((By.ID,"readcontractiframe")))
expandall = wait.until(EC.element_to_be_clickable((By.XPATH,"//a[@onclick='expandCollapseAll()']")))
expandall.click()
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/315541.html
