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

Solution 1:

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.

Solution 2:

This 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

...implies that the desired element wasn't clickable as some other element obscures it.


There are multiple approaches to address this issue and a couple of them are as follows:

  • As you intent to invoke click() you need to induce WebDriverWait inconjunction with the WebDriverWaitWebDriverWait for the element_to_be_clickable() and you can use either of the following Locator Strategies:

    • Using CSS_SELECTOR:

      WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "span.taLnk.ulBlueLinks"))).click()
      
    • Using XPATH:

      WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//span[@class='taLnk ulBlueLinks']"))).click()
      
  • Incase the error ...another element obscures it... still persists first you need to induce WebDriverWait inconjunction with the expected_conditions for the invisibility_of_element() of the blocking element as follows:

    • Using CSS_SELECTOR:

      WebDriverWait(driver, 20).until(EC.invisibility_of_element((By.CSS_SELECTOR, "div.loadingWhiteBox")))
      WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "span.taLnk.ulBlueLinks"))).click()
      
    • Using XPATH:

      WebDriverWait(driver, 20).until(EC.invisibility_of_element((By.XPATH, "//div[@class='loadingWhiteBox']")))
      WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//span[@class='taLnk ulBlueLinks']"))).click()
      
  • If the issue still persists you can use the execute_script() method as follows:

    • Using CSS_SELECTOR:

      WebDriverWait(driver, 20).until(EC.invisibility_of_element((By.CSS_SELECTOR, "div.loadingWhiteBox")))
      driver.execute_script("arguments[0].click();", WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "span.taLnk.ulBlueLinks"))))
      
    • Using XPATH:

      WebDriverWait(driver, 20).until(EC.invisibility_of_element((By.XPATH, "//div[@class='loadingWhiteBox']")))
      driver.execute_script("arguments[0].click();", WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//span[@class='taLnk ulBlueLinks']"))))
      

Note

You have to add the following imports :

from selenium.webdriver.support.ui import WebDriverWait       
from selenium.webdriver.common.by import By       
from selenium.webdriver.support import expected_conditions as EC

Solution 3:

You can wait until the element gone,

WebDriverWait wait = new WebDriverWait(driver, 30);
wait.until(ExpectedConditions.invisibilityOfElementLocated(By.className("loadingWhiteBox")));

Solution 4:

for Selenide

WebElement element = selenide_element.toWebElement();
WebDriverRunner.driver().executeJavaScript("arguments[0].click();", element);