我在 Python 中使用 Selenium 進行抓取。
當我嘗試單擊按鈕標簽時顯示以下錯誤。
ElementClickInterceptedException: Message: element click intercepted: Element <button id="pos-list" >...</button> is not clickable at point
HTML
<div id="order-bar">
<div id="order-bar-menu">
<button id="order-list" class="menu-btn-select">orderlist</button>
<button id="pos-list" class="menu-btn-normal">positionlist</button>
...
Python
pos = WebDriverWait(driver, 20).until(EC.visibility_of_element_located((By.XPATH, '//*[@id="pos-list"]')))
print(pos.text)
pos.click()
print(pos.text)positionlist按我的預期列印。
如何單擊此按鈕元素?
如果您能給我一些提示,將不勝感激。
uj5u.com熱心網友回復:
嘗試:
pos = WebDriverWait(driver, 20).until(EC.visibility_of_element_located((By.XPATH, '//*[text()="positionlist"]')))
pos.click()
或者
pos = WebDriverWait(driver, 20).until(EC.visibility_of_all_elements_located((By.XPATH, '//*[@id="order-bar"]/div/button')))
pos[1].click()
或 js 執行并單擊()
pos = WebDriverWait(driver, 20).until(EC.visibility_of_element_located((By.XPATH, '//*[@id="pos-list"]')))
driver.execute_script("arguments[0].click();", pos)
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/475494.html
上一篇:如何為DjangoRestFrameWork中具有兩個ManyToManyFields的模型撰寫__str__方法的測驗用例?
