Selenium "Element is not clickable at point" error in Firefox

13,269

Solution 1

This happens in the below cases-

  • When the element is loaded into the DOM, but the position is not fixed on the UI. There can be some other div or images that are not loaded completely.

  • The page is getting refreshed before it is clicking the element.

Workaround

  • Use Thread.sleep before actions on each web element in UI, but it is not a good idea.
  • Use WebDriverWait ExpectedConditions.

I was facing the same issue, the page load time was more and a loading icon was overlapping on entire web page.

To fix it, I have implemented WebDriverWait ExpectedConditions, which waits for the loading icon to disappear before performing click action on an element

Call this function before performing an action (I am using data driven framework)

public void waitForLoader () throws Exception  {
  try {
   String ObjectArray[]=ObjectReader.getObjectArray("LoadingIcon"); 
    if(checkElementDisplayed(ObjectArray[3],ObjectArray[2]))
    {
     WebDriverWait wait = new WebDriverWait(remotewebdriver,10); 
     wait.until(ExpectedConditions.invisibilityOfElementLocated(By.xpath(ObjectArray[3])));
    }
   } catch (NoSuchElementException e) {
   System.out.println("The page is loaded successfully");
   }
  }

Solution 2

My same problem is solved by Javascript, Please try following code instead of selenium click

WebElement rateElement = driver.findElement(By.xpath(xpathContenRatingTab));
((JavascriptExecutor)driver).executeScript("arguments[0].click();", rateElement);

Solution 3

If your problem is that the element is scrolled off the screen (and as a result under something like a header bar), you can try scrolling it back into view like this:

private void scrollToElementAndClick(WebElement element) { 
int yScrollPosition = element.getLocation().getY(); 
js.executeScript("window.scroll(0, " + yScrollPosition + ");"); 
element.click(); }

if you need you could also add in a static offset (if for example you have a page header that is 200px high and always displayed):

public static final int HEADER_OFFSET = 200; 
private void scrollToElementAndClick(WebElement element) { 
int yScrollPosition = element.getLocation().getY() - HEADER-OFFSET; 
js.executeScript("window.scroll(0, " + yScrollPosition + ");"); 
element.click(); 
}

You can direct click using JavascriptExecutor (Not recommanded)

WebElement element= driver.findElement(By."Your Locator"));

JavascriptExecutor executor = (JavascriptExecutor) driver;
executor.executeScript("arguments[0].click();", element);

Hope it will help you :)

Solution 4

I had the same problem and I solved it using certain capability. While you are using FirefoxDriver, you can set "overlappingCheckDisabled" to true to solve your problem.

capabilities.setCapability("overlappingCheckDisabled", true);

Solution 5

Careful matching of the Selenium jar version with the Firefox version can fix the issue. Selenium should automatically scroll an element into view if it isn't on the page. Forcing an element into view with JavaScript is unnecessary.

We never see this issue in Firefox 31.5.0 with selenium-server-standalone-2.44.0.jar, however when upgrading to Firefox 38.7.0 with selenium-server-standalone-2.52.0.jar, it became an issue.

See https://github.com/seleniumhq/selenium/issues/1543

Share:
13,269
emery
Author by

emery

I'm currently developing an automated regression suite for a fairly large PHP application in watir-webdriver. I also dedicate significant effort towards not spending too much time playing Skyrim.

Updated on July 30, 2022

Comments

  • emery
    emery almost 2 years

    In regards to the Webdriver error

    Element is not clickable at point (X, Y). Another element would recieve the click instead.
    

    For ChromeDriver, this is addressed at Debugging "Element is not clickable at point" error, however the issue can occur in Firefox as well.

    What are the best ways to resolve this when it occurs in FirefoxDriver?

  • ddavison
    ddavison about 8 years
    this is very misleading. it is up to the manufacturer of the driver to determine what the click actually does, and where and how it clicks. do you have sources to show that it clicks the "top left" by default? if so, which browsers
  • Chuck Brown
    Chuck Brown about 8 years
    True each driver could be different. My assumption comes from the casting of a webElement to a Locatable gives the top left corner location.
  • emery
    emery about 8 years
    This type of response is useful, however Selenium should do this automatically, so I think the better solution is to match the Firefox and Selenium versions appropriately.
  • Avinash Jadhav
    Avinash Jadhav about 8 years
    @ShubhramJain What is arguments[0].click() here because I am getting this error for above code org.openqa.selenium.WebDriverException: arguments[0].click is not a function
  • jmreicha
    jmreicha over 7 years
    Why is it not recommended to use javascriptExcutor?
  • David Clarke
    David Clarke almost 7 years
    This worked for me when I have tried most of the other suggestions unsuccessfully. SendKeys worked for Chrome but not Firefox. Thank you.
  • murali selenium
    murali selenium over 6 years
    after using different ways to click to over come this issue, this one only helps me.
  • MatMat
    MatMat over 6 years
    Thank you sir!! Updating chromedriver and matching the standalone server with selenium version in gradle worked :)
  • emery
    emery over 6 years
    @sircapsalot I wouldn't fully agree that it is "very misleading", since ActionBuilder is a valid solution to the error in many cases... but you make a valid point about the driver manufacturer possibly not always defaulting to the top left corner. I edited the post accordingly.
  • wutzebaer
    wutzebaer over 5 years
    Seems that javascriptExcutor does not wait until new page is loaded when clicking a link
  • Shubham Jain
    Shubham Jain over 5 years
    yes it will not wait. you need to add ExpectedConditions before trigger it