Python & Selenium: ElementClickInterceptedException: 消息:元素点击拦截错误

Python & Selenium: ElementClickInterceptedException: Message: element click intercepted error

我在 Python 中使用 Selenium 进行抓取。

当我尝试点击按钮标签时显示以下错误。

ElementClickInterceptedException: Message: element click intercepted: Element <button id="pos-list" class="menu-btn-normal">...</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

如何单击此按钮元素?

如果你能给我一些提示,我将不胜感激。

尝试:

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)