ElementClickInterceptedException:元素点击被拦截: [英] ElementClickInterceptedException: element click intercepted:

查看:4086
本文介绍了ElementClickInterceptedException:元素点击被拦截:的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Selenium + python在wordpress插件上提交一种表单.当我按下发布按钮时,它给出了一个错误.

I'm trying to submit one form on wordpress plugin using selenium + python. When I press publish button , it is giving an error.

ElementClickInterceptedException:元素点击被拦截:Element 在点(728,15)处,不能单击type ="submit" name ="publish" id ="publish" class ="button button-primary button-large" value ="Publish">.其他元素将获得点击: ...

ElementClickInterceptedException: element click intercepted: Element type="submit" name="publish" id="publish" class="button button-primary button-large" value="Publish"> is not clickable at point (728, 15). Other element would receive the click: ...

我尝试了以下解决方案: 使用了动作驱动程序,但是没有用. 使用了webdriverwait()函数,该函数不起作用. 使用过的Xpath,CSS选择器,ID-在所有三个中都给出相同的错误.

I have tried following solutions: Used action driver, but it didn't work. Used webdriverwait() function, it didn't work. Used Xpath, CSS selector, ID - It's giving same error in all three.

 `    browser.find_element_by_css_selector("""#save-post""").click()

    WebDriverWait(driver, 90).until(EC.element_to_be_clickable((By.ID, "save-post"))).click()
`

请注意,当我在python控制台中运行该特定行时,它正在工作.但是在运行完整脚本时,它会显示错误.

门户网站上有很多类似的问题,但是没有一个起作用.请帮助我解决这个问题.

There are so many similar questions on portal but none of them worked. Kindly help me to solve this issue.

推荐答案

好的,答案是错误消息-"其他元素将获得点击:... " 当我刚开始使用硒时,我遇到了同样的问题,无法找出问题所在. "其他元素会获得点击:... "表示您的元素上方(重叠)有其他元素(弹出窗口,页面变灰(加载时禁用,某些JS运行)),因此,当Selenium尝试单击您的元素时,实际上是单击了该阻止元素. Selenium的运行速度非常快,并且在它变得可点击之前单击,这就是为什么您无法单击它-"当我在python控制台中运行该特定行时,它正在工作" .sleep()5到10秒.如果是这种情况,那么您可以使用等待或添加条件,然后再找到您的元素来检查阻止单击您的元素的元素是否不存在,然后您单击您的元素.

ok, the answer is in error message - "Other element would receive the click: ..." I had the same problem when I just started using selenium, couldn't figure out what's the problem. "Other element would receive the click: ..." means there is other element above(overlapping) your element(pop up window, page is grayed out(disabled while loading, Some JS running)), so when Selenium trying to click on your element its actually clicking on that blocking element. Selenium is running really fast and clicking before its become clickable, that's why u are not able to click on it - "when I run that specific line in python console, it is working" Try to click after time.sleep() 5-10 sec. If this is the case then you can use wait or add condition before find your element to check that element that prevent from clicking on you element is not there then u click on your element.

这篇关于ElementClickInterceptedException:元素点击被拦截:的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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