无法单击元素:Splinter/Selenium 中的 ElementClickInterceptedException [英] Can not click on a Element: ElementClickInterceptedException in Splinter / Selenium

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

问题描述

我正在尝试抓取页面,但有时无法单击链接/按钮.

I'm trying to scrape a page, but I sometimes have trouble clicking a link/button.

当网页加载时,loadingWhiteBox"会先出现然后几秒后消失(但它会保留在HTML代码中)只要该框出现在网站上,我就无法点击链接并收到以下错误消息:

When the web page loads, then the "loadingWhiteBox" will appear first and then disappear after a few seconds (but it will remain in the HTML code) as long as the box is appears on the website, I can not click on the link and get following error message:

selenium.common.exceptions.ElementClickInterceptedException: Message: 
Element <span class="taLnk ulBlueLinks"> is not clickable at point 
(318.3000030517578,661.7999877929688) because another element <div 
class="loadingWhiteBox"> obscures it

有什么办法可以解决这个问题吗?我已经尝试使用以下命令:

Is there any way to work around this? I've already tried working with the following command:

driver.is_element_present_by_css('div[class*="loadingWhiteBox"]')

但该元素即使在不活动时也存在.

But the element is present even when it's not active.

推荐答案

您可以尝试以下两种方法来点击元素.

You can try the below 2 methods to click on element.

element = driver.find_element_by_css('div[class*="loadingWhiteBox"]')
driver.execute_script("arguments[0].click();", element)

element = driver.find_element_by_css('div[class*="loadingWhiteBox"]')
webdriver.ActionChains(driver).move_to_element(element ).click(element ).perform()

希望这会奏效.

这篇关于无法单击元素:Splinter/Selenium 中的 ElementClickInterceptedException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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