Python Selenium 错误 - 在点 (207.1666717529297,25) 处不可点击,因为另一个元素 <div id="overley"class =“over_ley">掩盖它 [英] Python Selenium error - is not clickable at point (207.1666717529297,25) because another element <div id="overley" class="over_ley"> obscures it

查看:53
本文介绍了Python Selenium 错误 - 在点 (207.1666717529297,25) 处不可点击,因为另一个元素 <div id="overley"class =“over_ley">掩盖它的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下代码 -

from selenium import webdriver从 selenium.webdriver.common.keys 导入密钥驱动程序 = webdriver.Firefox()driver.get("url")username = driver.find_element_by_id("登录ID")pwd = driver.find_element_by_id("密码")username.send_keys('usrnme')pwd.send_keys('pswd')Login = driver.find_element_by_id("Button2")登录.click()Create = driver.find_element_by_xpath("///*[@title='创建事件']")创建.click()

每当我在脚本中或批量运行此代码时,我都会遇到以下错误 -

回溯(最近一次调用最后一次): 中的文件P:\Selenium\helpline1.py",第 15 行创建.click()文件P:\Selenium\python-3.5.1\lib\site-packages\selenium\webdriver\remote\webelement.py",第80行,点击self._execute(Command.CLICK_ELEMENT)文件P:\Selenium\python-3.5.1\lib\site-packages\selenium\webdriver\remote\webelement.py",第 628 行,在 _execute 中返回 self._parent.execute(command, params)文件P:\Selenium\python-3.5.1\lib\site-packages\selenium\webdriver\remote\webdriver.py",第312行,在执行中self.error_handler.check_response(响应)文件P:\Selenium\python-3.5.1\lib\site-packages\selenium\webdriver\remote\errorhandler.py",第 237 行,在 check_response引发异常类(消息,屏幕,堆栈跟踪)selenium.common.exceptions.ElementClickInterceptedException:消息:元素 在点 (207.1666717529297,25) 处不可点击,因为另一个元素 

掩盖它

登录该站点的过程完美无缺,但之后单击元素时出现此错误(即下一行代码).

此外,当我在 Python IDLE 或 Python CLI 中手动逐行运行此代码时,它运行时没有任何错误.仅在 IDLE 或 Python CLI 中的脚本/批处理模式下发出

谢谢推荐.

如果在您尝试执行单击时显示叠加层,您可能需要等到叠加层关闭:

from selenium.webdriver.common.by import By从 selenium.webdriver.support.ui 导入 WebDriverWait从 selenium.webdriver.support 导入 expected_conditions 作为 EC...Create = driver.find_element_by_xpath("///*[@title='创建事件']")WebDriverWait(driver, 10).until_not(EC.visibility_of_element_located((By.ID, "overley")))创建.click()

I have below code -

from selenium import webdriver
from selenium.webdriver.common.keys import Keys
driver = webdriver.Firefox()
driver.get("url")
username = driver.find_element_by_id("LoginID")
pwd = driver.find_element_by_id("Password")
username.send_keys('usrnme')
pwd.send_keys('pswd')
Login = driver.find_element_by_id("Button2")
Login.click()
Create = driver.find_element_by_xpath("//*[@title='Create Incident']")
Create.click()

Whenever I am running this code in script or in batch I am getting below error -

Traceback (most recent call last):
  File "P:\Selenium\helpline1.py", line 15, in <module>
    Create.click()
  File "P:\Selenium\python-3.5.1\lib\site-packages\selenium\webdriver\remote\webelement.py", line 80, in click
    self._execute(Command.CLICK_ELEMENT)
  File "P:\Selenium\python-3.5.1\lib\site-packages\selenium\webdriver\remote\webelement.py", line 628, in _execute
    return self._parent.execute(command, params)
  File "P:\Selenium\python-3.5.1\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 312, in execute
    self.error_handler.check_response(response)
  File "P:\Selenium\python-3.5.1\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 237, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.ElementClickInterceptedException: Message: Element <a id="anc" class="RedirectTab" href="javascript:WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions("anc", "", true, "", "", false, true))"> is not clickable at point (207.1666717529297,25) because another element <div id="overley" class="over_ley"> obscures it

Login to the site happens perfectly but after that this error in clicking an element (that is the next line of code).

Also when I am running this code line by line manually in Python IDLE or Python CLI it runs without any error. Issue just in script/batch mode in IDLE or Python CLI

Thanks to suggest.

解决方案

If overlay displayed while you're trying to perform a click, you might need to wait until overlay is closed:

from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC


...
Create = driver.find_element_by_xpath("//*[@title='Create Incident']")
WebDriverWait(driver, 10).until_not(EC.visibility_of_element_located((By.ID, "overley")))
Create.click()

这篇关于Python Selenium 错误 - 在点 (207.1666717529297,25) 处不可点击,因为另一个元素 &lt;div id="overley"class =“over_ley">掩盖它的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆