Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
401 views
in Technique[技术] by (71.8m points)

python - Can not click on a Element: ElementClickInterceptedException in Splinter / Selenium

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

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.

Question&Answers:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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()

hope this will work.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...