Dia*_*e12 2 html python selenium google-chrome selenium-chromedriver
我正在尝试使用 Selenium 单击此 URL 上“关于此节目”下的“显示更多”:
这是我的代码:
#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
Run Code Online (Sandbox Code Playgroud)
我收到错误:
selenium.common.exceptions.ElementClickInterceptedException: Message: element click intercepted:
.</div> is not clickable at point (477, 9). Other element would receive the click:
Run Code Online (Sandbox Code Playgroud)
这是我尝试单击的 div 的照片:
因此,似乎有什么东西阻止了页面点击。我该如何解决这个问题?
小智 5
我看到弹出一个对话框,要求用户登录。这可能会中断点击。
更好的方法是:
这应该有效:
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)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
7925 次 |
| 最近记录: |