【问题标题】:Cant click on button [duplicate]无法点击按钮[重复]
【发布时间】:2019-10-25 12:46:31
【问题描述】:

我正在尝试单击下面给出的 xpath 提供的按钮。 它显示此错误:

raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.ElementClickInterceptedException: Message: element click intercepted: Element <a href="http://gogoanime.io/category/one-piece#disqus_thread">...</a> is not clickable at point (650, 736). Other element would receive the click: <div style="position:fixed;z-index:9999;background:#ffc119;bottom:0;text-align:center;color:#000;width:100%;padding:10px 0;font-weight:600;">...</div>

在 cmd 中。

import requests
from bs4 import BeautifulSoup
from selenium import webdriver

driver = webdriver.Chrome()
url = "https://www5.gogoanime.tv/category/one-piece"
driver.maximize_window()
driver.get(url)
content = driver.page_source.encode('utf-8').strip()
soup = BeautifulSoup(content,'html.parser')
#btn_comment_div = soup.find('div',{'class':'specialButton'})
#btn_comment = btn_comment_div.find('a')
btn_comment = driver.find_element_by_xpath('/html/body/div[2]/div/div/section/section[1]/div[1]/div[7]/div[1]/div/div/a')
btn_comment.click()

【问题讨论】:

  • @Hardik Mehta 您应该提供您想要点击的链接的屏幕截图或名称。

标签: python selenium web-scraping beautifulsoup


【解决方案1】:

在 selenium 无法点击元素的这种情况下,执行 javascript 点击将解决问题。 将btn_comment.click() 替换为driver.execute_script('arguments[0].click();',btn_comment)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-07-14
    • 2011-08-20
    • 1970-01-01
    • 1970-01-01
    • 2015-02-19
    • 2020-05-05
    相关资源
    最近更新 更多