0

I am using java and selenium. I have a pop-up that renders every time I click any button in it and after finishing what I want I click "X" button this exception is thrown: org.openqa.selenium.WebDriverException: unknown error: Element is not clickable at point (834, 307). Other element would receive the click:

The problem here is that the "button" and the "img" refers to the same element("X" button). I am getting the Element by the class name.

I tried to wait some time before the click but it fails and throws the same exception frequently. I tried also to make the click on the "img" but it fails and another exception is thrown: org.openqa.selenium.WebDriverException: unknown error: Element is not clickable at point (834, 307). Other element would receive the click:

Menna
  • 13
  • 6

2 Answers2

0

It usually happens when the element is not fully displayed on the UI or some part of it is displayed on the UI, and if the selenium tries to click on it, you get the Element is not clickable exception.

To solve it, you can first scroll to the element using the javascript scroll method and then you can click it.
You can do it like:

// Make a generic method to scroll to the element
public void scrollToElement(WebElement element) {
    executeScript("window.scrollTo(arguments[0],arguments[1])", element.getLocation().x, element.getLocation().y);
}

// Find the element, call the scroll method and then click on the element
WebElement element = driver.findElement(locator);
scrollToElement(element);
element.click();
Sameer Arora
  • 4,439
  • 3
  • 10
  • 20
0

If it is a web pop-up , try handling it as alert.

Alert a = driver.switchTo().alert();
a.accept();
a.dismiss();

accept() is to say OK/Yes the alert and dismiss() is to close/say No or Cancel to the alert.