简体   繁体   English

ElementClickInterceptedException: 元素点击被拦截。 其他元素会收到点击:Selenium Python

[英]ElementClickInterceptedException: element click intercepted. Other element would receive the click: Selenium Python

I have seen other questions about this error but my case is that in my program the other element should receive the click.我已经看到有关此错误的其他问题,但我的情况是,在我的程序中,另一个元素应该收到点击。 In details: the webdriver is scrolling through google search and it must click every website it finds but the program is preventing that.详细说明:webdriver 正在滚动谷歌搜索,它必须点击它找到的每个网站,但程序阻止了它。 How can I make it NOT search the previous site it clicked?我怎样才能让它不搜索它点击的上一个网站?

This is the function.这就是功能。 The program is looping it and after the first loop it scrolls down and the error occurs:程序正在循环它,在第一个循环之后它向下滚动并发生错误:

def get_info():
browser.switch_to.window(browser.window_handles[2])
description = WebDriverWait(browser, 10).until(
    EC.presence_of_element_located((By.TAG_NAME, "h3"))
).text

site = WebDriverWait(browser, 10).until(
    EC.presence_of_element_located((By.TAG_NAME, "cite"))
)
site.click()

url=browser.current_url
#removes the https:// and the / of the url
#to get just the domain of the website
try:
    link=url.split("https://")
    link1=link[1].split("/")
    link2=link1[0]
    link3=link2.split("www.")
    real_link=link3[1]

except IndexError:
    link=url.split("https://")
    link1=link[1].split("/")
    real_link=link1[0]

time.sleep(3)
screenshot=browser.save_screenshot("photos/"+"(" + real_link + ")" + ".png")
global content
content=[]
content.append(real_link)
content.append(description)
print(content)
browser.back()
time.sleep(5)
browser.execute_script("window.scrollBy(0,400)","")
time.sleep(5)

You can create a list of clicked website and check every time if that link is clicked or not.您可以创建一个点击过的网站列表,并在每次点击该链接时检查。 Here's the demo code :这是演示代码:

clicked_website=[]

url=browser.current_url
clicked_website.append(url)

# Now while clicking
if <new_url> not in clicked_website:
    <>.click()

This is just an idea how to implement.这只是一个如何实施的想法 Your code is mess, I didn't understand clearly so, implement in your code by yourself.你的代码一团糟,我没看明白,你自己在代码中实现。

Python ElementClickInterceptedException:元素<button...is not clickable. other element would receive the click:< div><div id="text_translate"><p> 我是 python 的新手,我试图抓取过去 6 个月内 Linkedin 用户的所有近期活动。 当用户没有喜欢的视频时,下面的代码可以正常工作。 如果有视频,则会收到 ElementClickInterceptedException 错误。 您能否为此提出解决方案?</p><p> 代码:</p><pre> for elem in driver.find_elements_by_xpath('.//a/div/span/span[@class = "visually-hidden"]|.//a/div/span/span/span[@class = "visually-hidden"]'): if elem.text == "7 months ago": break else: print(elem.text) try: print ("in try") button["key%s" %i] = WebDriverWait(driver, 30).until(expected_conditions.presence_of_element_located((By.XPATH, "//*[@id='main']/div/div[2]/div/span/button[@class='artdeco-button artdeco-button--muted artdeco-button--1 artdeco-button--full artdeco-button--secondary ember-view']"))) hover = ActionChains(driver).move_to_element(button.get("key%s" %i)) hover.perform() button.get("key%s" %i).click() i = i+1 except exceptions.StaleElementReferenceException as e: element = driver.find_element_by_xpath("//*[@id='main']/div/div[2]/div/span/button[@class='artdeco-button artdeco-button--muted artdeco-button--1 artdeco-button--full artdeco-button--secondary ember-view']") driver.execute_script("arguments[0].click();", element) print(e)</pre><p> 这是显示的错误:</p><pre> ElementClickInterceptedException at /login/ Message: element click intercepted: Element &lt;button tabindex="-1" id="ember631" class="artdeco-button artdeco-button--muted artdeco-button--1 artdeco-button--full artdeco-button--secondary ember-view" type="button"&gt;...&lt;/button&gt; is not clickable at point (249, 547). Other element would receive the click: &lt;img width="600" src="https://media-exp1.licdn.com/dms/image/C4E22AQHboa3Imyqsew/feedshare-shrink_800/0/1619094377786?e=1622678400&amp;amp;v=beta&amp;amp;t=oa-7gYnDMsfdopCC30LWGu4sv2R8TLPN6drB_Q5IQME" loading="lazy" height="750" alt="No alternative text description for this image" id="ember902" class="ivm-view-attr__img--centered feed-shared-image__image feed-shared-image__image--constrained lazy-image ember-view"&gt;</pre><p> 提前致谢!</p></div></button...is> - Python ElementClickInterceptedException: Element <button...is not clickable. Other element would receive the click:

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 ElementClickInterceptedException: 消息: 元素点击被拦截: <label>Selenium 和 Python 无法点击</label>元素 - ElementClickInterceptedException: Message: element click intercepted: Element <label> is not clickable with Selenium and Python Python & Selenium:ElementClickInterceptedException:消息:元素点击拦截错误 - Python & Selenium: ElementClickInterceptedException: Message: element click intercepted error ElementClickInterceptedException:消息:元素点击被拦截: - ElementClickInterceptedException: Message: element click intercepted: selenium.common.exceptions.ElementClickInterceptedException:消息:元素点击被拦截:元素不可点击 Selenium 和 Python - selenium.common.exceptions.ElementClickInterceptedException: Message: element click intercepted: Element is not clickable with Selenium and Python Selenium ElementClickInterceptedException: Other element would receive the click error click Like button on Instagram page - Selenium ElementClickInterceptedException: Other element would receive the click error clicking Like button on Instagram page Python ElementClickInterceptedException:元素<button...is not clickable. other element would receive the click:< div><div id="text_translate"><p> 我是 python 的新手,我试图抓取过去 6 个月内 Linkedin 用户的所有近期活动。 当用户没有喜欢的视频时,下面的代码可以正常工作。 如果有视频,则会收到 ElementClickInterceptedException 错误。 您能否为此提出解决方案?</p><p> 代码:</p><pre> for elem in driver.find_elements_by_xpath('.//a/div/span/span[@class = "visually-hidden"]|.//a/div/span/span/span[@class = "visually-hidden"]'): if elem.text == "7 months ago": break else: print(elem.text) try: print ("in try") button["key%s" %i] = WebDriverWait(driver, 30).until(expected_conditions.presence_of_element_located((By.XPATH, "//*[@id='main']/div/div[2]/div/span/button[@class='artdeco-button artdeco-button--muted artdeco-button--1 artdeco-button--full artdeco-button--secondary ember-view']"))) hover = ActionChains(driver).move_to_element(button.get("key%s" %i)) hover.perform() button.get("key%s" %i).click() i = i+1 except exceptions.StaleElementReferenceException as e: element = driver.find_element_by_xpath("//*[@id='main']/div/div[2]/div/span/button[@class='artdeco-button artdeco-button--muted artdeco-button--1 artdeco-button--full artdeco-button--secondary ember-view']") driver.execute_script("arguments[0].click();", element) print(e)</pre><p> 这是显示的错误:</p><pre> ElementClickInterceptedException at /login/ Message: element click intercepted: Element &lt;button tabindex="-1" id="ember631" class="artdeco-button artdeco-button--muted artdeco-button--1 artdeco-button--full artdeco-button--secondary ember-view" type="button"&gt;...&lt;/button&gt; is not clickable at point (249, 547). Other element would receive the click: &lt;img width="600" src="https://media-exp1.licdn.com/dms/image/C4E22AQHboa3Imyqsew/feedshare-shrink_800/0/1619094377786?e=1622678400&amp;amp;v=beta&amp;amp;t=oa-7gYnDMsfdopCC30LWGu4sv2R8TLPN6drB_Q5IQME" loading="lazy" height="750" alt="No alternative text description for this image" id="ember902" class="ivm-view-attr__img--centered feed-shared-image__image feed-shared-image__image--constrained lazy-image ember-view"&gt;</pre><p> 提前致谢!</p></div></button...is> - Python ElementClickInterceptedException: Element <button...is not clickable. Other element would receive the click: selenium.common.exceptions.ElementClickInterceptedException:消息:元素点击被拦截 - selenium.common.exceptions.ElementClickInterceptedException: Message: element click intercepted ElementClickInterceptedException:消息:使用 Selenium WebDriver 拦截元素点击 - ElementClickInterceptedException: Message: element click intercepted using Selenium WebDriver ElementClickInterceptedException:消息:元素单击拦截元素不可单击错误单击使用 Selenium 和 Python 的单选按钮 - ElementClickInterceptedException: Message: element click intercepted Element is not clickable error clicking a radio button using Selenium and Python 单击拦截,其他元素将收到单击。 允许其他元素接收点击 - Click intercepted, other element would receive the click. Allow this other element to receive the click
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM