Clicking Elements When Intercepted by Others: Tackling ElementClickInterceptedException in Splinter/Selenium
When scraping web pages, clicking on certain elements can prove challenging due to the presence of obscuring elements. In Selenium, the ElementClickInterceptedException is raised when an attempt is made to click on an element that is obscured by another element. A common scenario is when a loading indicator, often denoted by a class like "loadingWhiteBox," appears temporarily on the page and prevents interaction with underlying elements.
To address this, consider the following methods:
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()
Both methods effectively circumvent the obscuring element and allow you to click on the intended target.
Disclaimer: All resources provided are partly from the Internet. If there is any infringement of your copyright or other rights and interests, please explain the detailed reasons and provide proof of copyright or rights and interests and then send it to the email: [email protected] We will handle it for you as soon as possible.
Copyright© 2022 湘ICP备2022001581号-3