emery
emery

Reputation: 9673

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

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?

Upvotes: 8

Views: 13718

Answers (8)

dan_udnas
dan_udnas

Reputation: 29

This Error coud ocur when for example u make to many accesses to some service , for example if u are making as I a bot .... For example instagram will block u for some period if u ar taged as blocked and then that error coud ocour not allowing u to click some elements in the page.

Try make another acount and switch to a vpn becouse probably your ip is already marked as blocked

Upvotes: 1

D.JCode
D.JCode

Reputation: 406

Try to maximize the browser when you are working with resolutions greater than 1024x768. It works for me in js.

 driver.manage().window().maximize();

Upvotes: 0

Chuck Brown
Chuck Brown

Reputation: 363

ActionBuilder can resolve the error. Sometimes there is another element in front of the object that needs to be clicked, so an ActionBuilder click to the location of the element may work in cases where a traditional click fails

    Actions actions = new Actions(driver);
    actions.moveToElement(clickElement).click().perform();

or try the middle of the element

    Actions actions = new Actions(driver);
    Integer iBottom = clickElement.getSize().height;
    Integer iRight = clickElement.getSize().width;
    actions.moveToElement(clickElement, iRight/2, iBottom/2).click().perform();

Upvotes: 1

Sumit2500
Sumit2500

Reputation: 183

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

Upvotes: 3

Lorenzo Fidalgo
Lorenzo Fidalgo

Reputation: 203

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

Upvotes: 2

Joe
Joe

Reputation: 51

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");
   }
  }

Upvotes: 5

Shubham Jain
Shubham Jain

Reputation: 17553

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

Upvotes: 3

emery
emery

Reputation: 9673

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

Upvotes: 2

Related Questions