selenium.common.exceptions.ElementClickInterceptedException解决办法

目标是定位提交元素,并点击,定位元素时,写的Xpath,可以精确指向元素,但无法定位
图片说明

1、原本的代码是
driver.find_element_by_xpath("html/body/div[12]/div[2]/div[1]/div[1]/div[3]/div[1]/button[2]/span").click()

报错信息如下:
File "D:\Program Files\python\lib\site-packages\selenium-3.13.0-py3.7.egg\selenium\webdriver\remote\webelement.py", line 628, in _execute
return self._parent.execute(command, params)
File "D:\Program Files\python\lib\site-packages\selenium-3.13.0-py3.7.egg\selenium\webdriver\remote\webdriver.py", line 320, in execute
self.error_handler.check_response(response)
File "D:\Program Files\python\lib\site-packages\selenium-3.13.0-py3.7.egg\selenium\webdriver\remote\errorhandler.py", line 242, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.ElementClickInterceptedException: Message: Element is not clickable at point (1174,526) because another element obscures it

改成如下代码后即可定位并点击成功:
tijiao=driver.find_element_by_xpath("html/body/div[12]/div[2]/div[1]/div[1]/div[3]/div[1]/button[2]/span")
driver.execute_script("arguments[0].click();",tijiao)

查看全部
yuna_0208
yuna_0208
2019/03/27 17:40
  • python
  • firefox
  • 点赞
  • 收藏
  • 回答
    私信

0个回复