Selenium error: element click intercepted:Other element would receive the click:

Selenium error: element click intercepted:Other element would receive the click:

我正在尝试使用 Selenium 在这个 URL 上点击“关于这个节目”下的“显示更多”:

https://www.bandsintown.com/e/1024477910-hot-8-brass-band-at-the-howlin'-wolf?came_from=253&utm_medium=web&utm_source=city_page&utm_campaign=event

这是我的代码:

#Get Event Info - expand 'read more'
    try:
        time.sleep(3)
        readMoreEvent = driver.find_element_by_xpath("//div[@class='xXGKBimvIBU_aEdJh3EF']").click();
        print("More Event Info Clicked")
    except (ElementNotVisibleException, NoSuchElementException, TimeoutException):
        pass

我收到一个错误:

selenium.common.exceptions.ElementClickInterceptedException: Message: element click intercepted:

.</div> is not clickable at point (477, 9). Other element would receive the click:

这是我要点击的 div 的照片:

所以,似乎有什么东西阻止了页面点击。我该如何解决这个问题?

我看到弹出一个对话框,要求用户登录。这可能会中断点击。

更好的方法是:

  1. 等待 link 可点击
  2. 捕获异常并使用替代方法点击link

这应该有效:

from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
from selenium.common.exceptions import ElementClickInterceptedException
from selenium.webdriver.chrome.options import Options
from time import sleep

options = Options()
options.add_argument("--disable-notifications")

driver = webdriver.Chrome(executable_path='D://chromedriver/100/chromedriver.exe', options=options)
wait = WebDriverWait(driver, 20)

url = "https://www.bandsintown.com/e/1024477910-hot-8-brass-band-at-the-howlin%27-wolf?came_from=253&utm_medium=web&utm_source=city_page&utm_campaign=event"

driver.get(url)

try:
    showmore_link = wait.until(EC.element_to_be_clickable((By.XPATH, '//div[@class="xXGKBimvIBU_aEdJh3EF"]')))
    showmore_link.click()

except ElementClickInterceptedException:
    print("Trying to click on the button again")
    driver.execute_script("arguments[0].click()", showmore_link)