Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

People also ask

Why click is not working in Selenium?

We can list the most common reasons for click problems as being one of the following: Wrong web element locations. The existence of a web element that obscures the web element that we want to click. The Selenium WebDriver works much faster than the response of the application.

How do you click on a non clickable element in Selenium?

Solution 4: Using Actions class in Selenium The exception “Element is not clickable at point” might be thrown when the element is not under focus or the action is being performed on the incorrect WebElement. In such cases, you have to switch to the actual element and perform the click action.

Is not clickable at point because another element obscures it Selenium?

We can get the error - Element is not clickable at point while trying to click a link in Selenium webdriver. This is common in chromedriver as the Chrome browser determines an element with point location. When the position of an element is changing and we make an attempt to click on it, this error is encountered.


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.


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

You can wait until the element gone,

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

for Selenide

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