python-3.x - ElementClickInterceptedException:消息:元素单击被拦截。其他元素会收到点击:Selenium Python
问题描述
我已经看到有关此错误的其他问题,但我的情况是在我的程序中,其他元素应该收到点击。详细信息:网络驱动程序正在通过谷歌搜索滚动,它必须点击它找到的每个网站,但程序阻止了这一点。我怎样才能让它不搜索它点击的上一个网站?
这就是功能。程序正在循环它,在第一个循环之后它向下滚动并发生错误:
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)
解决方案
推荐阅读
- java - Eclipse 应用程序打开但更新到 macOS Big Sur 后无法打开文件
- ubuntu - 使用 RTX3090 安装 Kubuntu 导致黑屏 -> Kubuntu 仍在运行
- php - 如何为 PHP 7.4 及更高版本编译 pcntl?
- mlt - mlt:格式化动态文本时间码?
- mule - 将 Mule 与 Runtime Manager 独立使用
- html - 字体属性 CSS 不起作用
- ios - Chatto 自定义单元格高度
- javascript - 更新 Firestore 上的规则后,我无法读取数据(React Native)
- html - 仅当它有自己的行时,img 才居中
- python - Python 股票脚本每 10 秒更新一次价格