網站的 HTML 快照:

該按鈕是“https://app.prizepicks.com/board”上的籃板按鈕。我嘗試過使用復制 xPath 功能,但這不起作用。
uj5u.com熱心網友回復:
嘗試等到元素出現或使用 time.sleep()
下面的 xpath 對我有用
反彈_btn = driver.find_element_by_xpath('//*[包含(文本(), "籃板")]') 反彈_btn.click()
uj5u.com熱心網友回復:
試試下面,
WebDriverWait(driver, 15).until(EC.element_to_be_clickable((By.XPATH, "//*[contains(text(), 'Rebounds')]"))).click()
不要忘記匯入
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
uj5u.com熱心網友回復:
要單擊文本為Rebounds的元素,您需要為element_to_be_clickable()誘導WebDriverWait,您可以使用以下解決方案:
driver.get("https://app.prizepicks.com/board")
WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//div[text()='Rebounds']"))).click()
注意:您必須添加以下匯入:
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/461088.html
標籤:Python 硒 硒网络驱动程序 路径 网络驱动程序等待
下一篇:硒網路驅動程式android
