1

I have a problem with the following exception:

org.openqa.selenium.WebDriverException: unknown error: Element is not clickable at point (1128, 997). Other element would receive the click...

My page object has a "buy now" button which I want to click.

@FindBy(xpath = ".//*[@id='summary-right-column-wrapper']/div[3]/a")
private WebElement buyNow;

And I have a getter with a explicit wait build in:

public WebElement getBuyNow() {
    return wait.until(ExpectedConditions.elementToBeClickable(buyNow));
}

When I call it:

final WebElement readyBuyNow = getBuyNow();
readyBuyNow.click();

I get the exception.

Why the element is still not clickable if I use the ExpectedConditionsalready?

Thanks! Best regards Robert

  • Are you are trying to click on the element after page loading/after closing popup ???? .Bcoz as per your error message I came to know that , you are trying to click element is not yet visible.so it is clicking on other element – QAMember Jun 1 '16 at 9:18
  • How can I tell Selenium that it should execute the click after the page is completely loaded? Is it not the default behaviour? – Robert Moszczynski Jun 1 '16 at 9:38
  • for that first you need to wait until the element is visible then you can perform action on it – QAMember Jun 1 '16 at 9:44
  • I do it already with ExpectedConditions.elementToBeClickable(buyNow). – Robert Moszczynski Jun 1 '16 at 9:47
  • Do it for ExpectedConditions.visibilityOfElementLocated(buyNow) – QAMember Jun 1 '16 at 9:54
3

The expected condition elementToBeClickable checks two things:

  • Visibility: it's not hidden per CSS rules (display: none)and has a height and width > 0
  • Clickable: the element may not have a disabled attribute

It's perfectly possible that those conditions are met and you're still getting that specific exception.

The most likely reason is some sort of pop-up, menu or autocomplete box appears over the element you're trying to click (which means nothing to Selenium in terms of 'visibility').

Solution: make sure you close any elements hovering over the item you're trying to click. Without having your specific website to test on, that's the best answer I can give (and it has been the solution for me every time I had this issue).

  • Thank you, but there are no elements hovering my targets. The page simply needs more time to load. As a workaround I use a sleep method for that. – Robert Moszczynski Jun 1 '16 at 11:01
  • Sleep is really bad crutch. Of course your code and do what you want. You should use ExpectedConditions, to wait for visibility of some element which is visible only after page loaded - your "buy" button might be a good candidate. – Peter M. - stands for Monica Jun 1 '16 at 14:26
  • @RobertMoszczynski It's possible what you're saying but the "Other element would receive the click" most definitely means your target element is already (or should be) visible. Do you have an URL to test on? – FDM Jun 1 '16 at 16:35
  • @RobertMoszczynski And are you sure your locator is selecting the element you want? Maybe there's a second element with the same locator, in which case you might select the wrong one. – FDM Jun 1 '16 at 17:18
  • 1. No, there is no public link to test on. 2. The locator is ok. Maybe there are multiple elements with the same `ìd``. I'll check it. – Robert Moszczynski Jun 3 '16 at 12:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.