By user1591169


2012-08-10 19:44:09 8 Comments

I see this only in Chrome.

The full error message reads:

"org.openqa.selenium.WebDriverException: Element is not clickable at point (411, 675). Other element would receive the click: ..."

The element that 'would receive the click' is to the side of the element in question, not on top of it and not overlapping it, not moving around the page.

I have tried adding an offset, but that does not work either. The item is on the displayed window without any need for scrolling.

30 comments

@Tony Lâmpada 2012-10-02 13:34:05

There seems to be a bug in chromedriver for that (the problem is that it's marked as won't fix) --> GitHub Link

(place a bounty on FreedomSponsors perhaps?)

There's a workaround suggested at comment #27. Maybe it'll work for you.

@Evan Knowles 2013-10-17 08:19:53

Seems fair - if the button isn't on the screen then it isn't really clickable.

@Roger Garza 2014-08-18 21:10:18

Comment #34 works best for me in Ruby

@Aaron 2014-12-31 17:55:59

Comment #85 helped me out (Protractor)

@Alex.Designworks 2015-05-06 06:10:30

This is not a bug. This is intended behaviour and it is correct. As other suggested, if element is outside of viewport - you need to scroll to it.

@dansalmo 2017-06-28 21:13:45

I tried Firefox and found it did not give this error, yet the click was still ignored. It turned out to be the a parent div had a height of zero. Once that was fixed both worked fine.

@Kunok 2018-11-02 13:59:34

so how you guys count comments? You go like with your finger, this is comment #1, this is comment #2, or there is actual link with comment markers?

@u-phoria 2015-02-18 12:24:30

Was getting this error when running tests headless with xvfb-run. They were working flawlessly locally. Using chrome, versions of webdriver / chromedriver / chrome / java etc all identical.

The ‘won’t fix’ bug in chromedriver - GitHub Link pointed out by Tony Lâmpada suggested this may be related to what is / isn't visible on the screen.

Help message for xvfb-run shows the following:

-s ARGS   --server-args=ARGS    arguments (other than server number and
                                "-nolisten tcp") to pass to the Xvfb server
                                (default: "-screen 0 640x480x8")

Changing the resolution for xvfb made the error go away:

xvfb-run -s "-screen 0 1280x1024x16" ...

@D.JCode 2018-10-30 08:23:22

Try to maximize the browser when you are working with resolutions greater than 1024x768.

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

@Ayush Goel 2018-10-28 12:47:58

WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(15));
wait.Until(SeleniumExtras.WaitHelpers.ExpectedConditions.ElementToBeClickable(By.<Id or anything>));

Hope this helps.

@sri 2018-06-28 09:58:08

The reason for this error is that the element that you are trying to click is not in the viewport (region seen by the user) of the browser. So the way to overcome this is by scrolling to the desired element first and then performing the click.

Javascript:

async scrollTo (webElement) {
    await this.driver.executeScript('arguments[0].scrollIntoView(true)', webElement)
    await this.driver.executeScript('window.scrollBy(0,-150)')
}

Java:

public void scrollTo (WebElement e) {
    JavascriptExecutor js = (JavascriptExecutor) driver; 
    js.executeAsyncScript('arguments[0].scrollIntoView(true)', e)
    js.executeAsyncScript('window.scrollBy(0,-150)')
}

@Osprey Eagle 2018-04-21 12:48:30

In Rselenium, this happened with code successfully used many times when a link was positioned at the top window border. Simple solution was to use sendKeysToElement() as follows.

if (unlist(webElem$isElementDisplayed())) {
    webElem$sendKeysToElement(list(key = "up_arrow"))  # Add "up arrow"..
    webElem$clickElement()  # ... before $clickElement

@Balram Singh 2017-10-12 15:12:49

In my case, it worked in Firefox but failed in Chrome. In Chrome, it got fixed after updating Chrome driver version to the latest.

@Dorian 2018-02-20 20:52:04

This question is 5+ years old and I still got the issue today, it was an overlay for me that I needed to remove

@kolibri 2013-11-14 13:34:29

I, too, wrestled with this problem. Code works fine in FF, fails on Chrome. What I was trying to do was to click a tickbox - if it wasn't in view, I'd scroll to view and then click. Even scrolling into view works in Chrome, only the bottom few pixels of the tickbox wasn't visible so webdriver refused to click on it.

My workaround is this:

WebElement element = _sectorPopup.findElement(...);

((Locatable) element).getCoordinates().inViewPort();
try {
    element.click();
} catch (Exception e) {
    new Actions(getWebDriver()).sendKeys(Keys.PAGE_DOWN).perform();
    element.click();
}

Chrome also has issues with sendKeys, using Actions is sometimes necessary. Obviously, you need to know which direction and how much you need to go so your mileage may vary. But I prefer this to the javascript hack, so I'm posting it here in case someone else will find it useful.

@Steve Staple 2017-12-20 14:15:39

Locatable is deprecated.

@XGillerX 2013-02-24 09:30:50

I had the same issue, tried all offered solutions but they did not work for me. eventually I used this:

JavascriptExecutor js = (JavascriptExecutor) driver;
js.executeScript("var evt = document.createEvent('MouseEvents');" + "evt.initMouseEvent('click',true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0,null);" + "arguments[0].dispatchEvent(evt);", findElement(element));

Hope this helps

@maoanz 2014-10-15 13:00:38

When I used element.click(), it works sometimes, sometimes not. Very good solution, it solves my problem.

@mishmaccas 2017-11-03 03:05:39

This was the only thing that worked for me to click on an iFrame svg link. Thanks Heaps dude!

@bewu 2014-04-02 10:26:06

You can also use JavaScript click and scrolling would be not required then.

IJavaScriptExecutor ex = (IJavaScriptExecutor)Driver;
ex.ExecuteScript("arguments[0].click();", elementToClick);

@Giovanni Bitliner 2017-08-20 17:50:11

Unbelievable! I wonder why selenium does not trash the click() method that they provide, given that there are conditions in which isDisplayed() and isEnabled() are not enough to click on an element, and this seems the only one solution. Thanks!

@User 2017-10-01 05:32:37

+1: This is the solution that worked for me. actions.MoveToElement didn't work for me in C# and the other scrolling solutions seemed a little fragile in that there was a chance the scrolling might not correctly get the element into view or the element's position on the page could change.

@Yashveer Rana 2017-10-06 06:39:31

this solution is the easiest if the element is not in view, but exists on the page

@Gideon Mulder 2017-10-30 08:41:56

@Giovanni Bitliner They do not provide this method since it is not a real user scenario. Users should also have to wait till the loader disappears. I think thats a wonderfull thing about selenium.

@Jeremias 2017-11-17 11:28:51

+1 Also worked for me. Just made added flwg method to my code: ` private void jsClick(IWebElement element, IWebDriver driver) { IJavaScriptExecutor ex = (IJavaScriptExecutor)driver; ex.ExecuteScript("arguments[0].click();", element); } ` invoked this way: 'jsClick(driver.FindElement(By.XPath("xpathOfTheElement"))); `

@chindirala sampath kumar 2017-12-19 08:12:40

Finally this solution worked!.

@Dharmang 2018-03-14 13:30:10

Yes, this is working for me. Also, You can use scrollIntoView() then click() for default effect..

@vijay pujar 2018-06-06 09:08:33

Having tried most of the above solutions to no avail, but this definitely worked for me (Selenium-3.12.0, Cucumber stack for Chrome Driver)

@Prabu Ananthakrishnan 2013-11-04 07:05:40

This is caused by following 3 types:

1.The element is not visible to click.

Use Actions or JavascriptExecutor for making it to click.

By Actions:

WebElement element = driver.findElement(By("element_path"));

Actions actions = new Actions(driver);

actions.moveToElement(element).click().perform();

By JavascriptExecutor:

JavascriptExecutor jse = (JavascriptExecutor)driver;

jse.executeScript("scroll(250, 0)"); // if the element is on top.

jse.executeScript("scroll(0, 250)"); // if the element is on bottom.

or

JavascriptExecutor jse = (JavascriptExecutor)driver;

jse.executeScript("arguments[0].scrollIntoView()", Webelement); 

Then click on the element.

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

For this, make the page to wait for few seconds.

3. The element is clickable but there is a spinner/overlay on top of it

The below code will wait until the overlay disppears

By loadingImage = By.id("loading image ID");

WebDriverWait wait = new WebDriverWait(driver, timeOutInSeconds);

wait.until(ExpectedConditions.invisibilityOfElementLocated(loadingImage));

Then click on the element.

@Don Simon 2015-05-21 16:32:42

There is a third type of cause, which is that your element is wrapped in a div or a span. The page can be fully loaded, and completely within the viewport, but Chromedriver will refuse to click it, where the webdriver for FF and IE have no issue. A real human has no clue that the span exists, and the browser doesn't care when you actually click it, as a human. Neither moving around, nor waiting will solve this issue; either avoid Chrome/chromedriver, or rewrite the page's HTML seem to be the only options for people in case 3.

@Peter Bernier 2015-07-08 18:47:03

@DonSimon I had the same issue that you did. I was able to get around it by using .SendKeys(Keys.Return) instead of .Click. This worked for me in Chrome where I was having this issue and in Firefox where I was having another similar issue on this particular link (anchor wrapped in a Div).

@G-J 2016-02-16 18:07:07

The solution suggested by @PeterBernier works well in the case where the element is wrapped in a div or a span. In Python I used .send_keys('\n') to simulate the click and work around the issue in Chrome.

@EsotericNonsense 2016-07-13 16:14:43

If an element is hidden by a div element the following code fixes it. executeJavascript("arguments[0].click();", selenium.findElement(locator));

@Steve Harrison 2016-07-18 11:59:30

the first solution works for me

@Chielus 2016-11-28 07:22:26

You can also wait for the element to be clickable. wait.Until(ExpectedConditions.ElementToBeClickable(webElemen‌​t));

@Kevin Zhao 2017-01-07 02:00:33

I tried Action and JavascriptExecutor, neither worked, but @PeterBernier solution worked for me, using `send_keys('\n') will click the button, not sure why though...

@BnMcG 2017-01-27 11:29:55

@PeterBernier's solution works for me. In my particular case, it seems that when Bootstrap is used to wrap a drop-down caret in a span, if the button only contains a caret, Selenium will not click on it. Sending a return key instead does work.

@Alex Che 2018-08-19 21:45:07

In my case I needed to send a space key: SendKeys(Keys.Space)

@tigersagar 2018-11-12 09:31:46

"ExpectedConditions.elementToBeClickable" with WebDriverWait works best in these cases. This will work if you are facing the isssue where webdriver is waiting too long. WebDriverWait wait = new WebDriverWait(driver, 5); WebElement element = wait.until(ExpectedConditions.elementToBeClickable(By.id("so‌​meid")));

@Zags 2017-06-06 19:34:13

If you have jQuery loaded on the page, you can execute the following javascript command:

"$('#" + element_id + "').click()"

Example using python executor:

driver.execute_script("$('#%s').click()" % element_id)

@Super Mario 2017-06-13 21:17:26

I do a kind of brute force of clicks and it works for me.

try:
    elem.click()
except:
    print "failed to click"
    size = elem.size
    mid_of_y = int(size["height"])/2
    stepts_to_do_to_left = int(size["width"])
    while stepts_to_do_to_left > 0:
        try:
            print stepts_to_do_to_left, mid_of_y
            action = webdriver.common.action_chains.ActionChains(driver)
            action.move_to_element_with_offset(elem, mid_of_y, stepts_to_do_to_left)
            action.click()
            action.perform()
            print "DONE CLICK"
            break
        except:
            pass

@Prabhjot Rai 2017-02-12 07:03:45

I was getting the same issue while running selenium script in python. Here is what I used to click on the element:

from selenium.webdriver.common.action_chains import ActionChains


ActionChains(driver).click(element).perform()

@Dee 2016-12-27 14:57:20

Explanation of error message:

The error message simply says, that the element you want to click on is present, but it is not visible. It could be covered by something or temporary not visible.

There could be many reasons why the element is not visible in the moment of the test. Please re-analyse your page and find proper solution for your case.

Solution for particular case:

In my case, this error occures, when a tooltip of the screen element i just clicked on, was poping over the element I wanted to click next. Defocus was a solution I needed.

  • Quick solution how to defocus would be to click to some other element in another part of the screen which does "nothing" resp. nothing happens after a click action.
  • Proper solution would be to call element.blur() on the element poping the tooltip, which would make the tooltip disapear.

@Gal Bracha 2016-10-01 13:19:47

When using Protractor this helped me:

var elm = element(by.css('.your-css-class'));
browser.executeScript("arguments[0].scrollIntoView();", elm.getWebElement());
elm.click();

@Huy Hóm Hỉnh 2016-09-15 10:01:21

I met this because a loading dialog cover on this element. I simplely solve it by add a waiting before working with the this element.

try {
        Thread.sleep((int) (3000));
    } catch (InterruptedException e) {
        //
        e.printStackTrace();
    }

Hope this help!

@Gokul 2017-02-07 10:55:09

In some cases(pages), this works.

@Bruno Marinho 2015-12-01 16:22:41

After testing all mentioned suggestions, nothing worked. I made this code. It works, but is not beautiful

public void click(WebElement element) {
    //https://code.google.com/p/selenium/issues/detail?id=2766 (fix)
    while(true){
        try{
            element.click();
            break;
        }catch (Throwable e){
            try {
                Thread.sleep(200);
            } catch (InterruptedException e1) {
                e1.printStackTrace();
            }
        }
    }
}

public void click(String css) {
    //https://code.google.com/p/selenium/issues/detail?id=2766 (fix)
    while(true){
        try{
            driver.findElement(By.cssSelector(css)).click();
            break;
        }catch (Throwable e){
            try {
                Thread.sleep(200);
            } catch (InterruptedException e1) {
                e1.printStackTrace();
            }
        }
    }
}

@rts 2016-04-18 07:15:28

If you're using the line below in your conf.js file, please comment it out and try again

browser.ignoreSynchronization = true;

@Xwris Stoixeia 2016-08-25 14:54:46

Wow, a lot of answers here, and many good ones.

I hope I'll add something to this from my experience.

Well guys, in my case there was a cookie overlay hiding the element occasionally. Scrolling to the element also works; but in my humble opinion (for my case, not a panacea for everyone) the simplest solution is just to go full screen (I was running my scripts on a 3/4 of the screen window)! So here we go:

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

Hope that helps!

@Michael Vehrs 2016-08-31 15:36:38

It helped in my case.

@Ohad Schneider 2016-04-29 15:21:56

This might happen if the element changes position while the driver is attempting to click it (I've seen this with IE too). The driver retains the initial position but by the time it actually gets to clicking on it, that position is no longer pointing to that element. The FireFox driver doesn't have this problem BTW, apparently it "clicks" elements programmatically.

Anyway, this can happen when you use animations or simply change the height of elements dynamically (e.g. $("#foo").height(500)). You need to make sure that you only click elements after their height has "settled". I ended up with code that looks like this (C# bindings):

if (!(driver is FirefoxDriver))
{
    new WebDriverWait(driver, TimeSpan.FromSeconds(10)).Until(
        d => d.FindElement(By.Id(someDynamicDiv)).Size.Height > initialSize);
}

In case of an animation or any other factor you can't easily query for, you can utilize a "generic" method that waits for the element to be stationary:

var prevLocation = new Point(Int32.MinValue, Int32.MinValue);
int stationaryCount = 0;
int desiredStationarySamples = 6; //3 seconds in total since the default interval is 500ms
return new WebDriverWait(driver, timeout).Until(d => 
{
    var e = driver.FindElement(By.Id(someId));
    if (e.Location == prevLocation)
    {
        stationaryCount++;
        return stationaryCount == desiredStationarySamples;
    }

    prevLocation = e.Location;
    stationaryCount = 0;
    return false;
});

@Levi Noecker 2016-09-16 12:50:06

This appears to be what I'm experiencing. I intermittently get the OP's "Other Element would..." exception, but screenshots show the modal is on the screen and element is not covered and I use waits before clicking. Turns out when the modal I'm clicking opens it actually slides down the page. Depending on when the selenium wait actual samples the DOM, the exception can be thrown if it caught the modal as it was moving.

@AndreyP 2016-02-20 00:13:46

You may simulate click with JS:

public void click(WebElement element) {
    JavascriptExecutor js =(JavascriptExecutor)driver;
    js.executeScript("document.elementFromPoint(" + element.getLocation().x + "," + element.getLocation().y + ").click();");
}

@virtual agent 07 2015-10-07 14:56:12

Instead of

webdriver.findElement(By.id("id1")).click();

try to use

click(By.id("id1"));

void click(final By byLocator) {
    waitFor(new ExpectedCondition<Boolean>() {
        @Override
        public Boolean apply(WebDriver driver) {
            WebElement element = driver.findElement(byLocator);
            if (element.isDisplayed()) {
                try {
                    element.click();
                    return true;
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
            return false;
        }

        @Override
        public String toString() {
            return "Element located " + byLocator + " clicked";
        }
    });
}

@JSDeveloper 2015-06-17 14:52:00

I had same exception while trying to click one of the radio buttons on my page. I used below Javascript and exeted using IJavaScriptExecutor. C# example

string script=" function clickCharity() {"+
"var InputElements = document.getElementsByName('Charity');"+
  "for (i=0; i<InputElements.length; i++){"+
    "if(InputElements[i].getAttribute('value') == 'true')"+
    "{"+
        "InputElements[i].click();"+
    "}"+
"}"+
"}";
var js=WebDriver as IJavaScriptExecutor;
js.ExecuteScript(script);

@CargoMeister 2015-05-19 18:23:37

It's funny, all the time I spent looking at the various responses, no one had tried the obvious, which of course, I hadn't either. If your page has the same id used multiple times, as mine did, ("newButton",) and the one you want is not the first one found, then you will in all likelihood get this error. The easiest thing to do (C#):

var testIt = driver.FindElements(By.Id("newButton"));

Note it's FindElements, not FindElement.

And then test to see how many results came back from the retrieval. If it's the second one, you can then use:

testit[1].Click();

Or get whomever reused ids to fix them.

@Sean Duggan 2015-11-05 18:48:43

If this is because there are multiple buttons by that ID and only one is displayed at a time, a superior solution involves using LINQ to find the first element that is visible (append .First(x => x.Visible) to the FindElements call) and click on that if it's not null.

@Jim Sowers 2015-05-07 18:08:19

In Visual Studio 2013, if you enable BrowserLink - it displays a BrowserLink navbar at the bottom of the screen. If the item you want to click is behind that navbar, it give the error. Disabling BrowserLink solved the problem for me.

@Adnan Ghaffar 2015-03-16 16:51:41

I am facing the same issue and I used delay and it is working fine my side. Page was getting refresh and getting the other locators.

Thread.sleep(2000);
        Click(By.xpath("//*[@id='instructions_container']/a"));

@Uri 2015-03-04 10:12:46

If you use Python:

from selenium import webdriver

action = webdriver.ActionChains(driver=self.driver)
action.move_to_element(to_element=self.driver.find_element_by_xpath(xpath="[xpath]"))
action.click()
action.perform()

@dankohn 2014-12-17 18:09:59

I had another bug where find_link on Chrome and Poltergeist could not click an A tag with an EM tag and some text inside of it, although it worked fine in Firefox and rack_test. The solution was to replace click_link(link) with:

find('a em', text: link).click

@dankohn 2014-12-15 19:51:05

I was getting this bug because I tested a hover and then needed to click on the link underneath the tooltip. The solution was to add page.find('.sp-logo').hover before click_link to get the tooltip out of the way.

Related Questions

Sponsored Content

1 Answered Questions

2 Answered Questions

2 Answered Questions

2 Answered Questions

WebDriverException: Element is not clickable at point

2 Answered Questions

[SOLVED] ExtnJS-“Element is not clickable at point” error

3 Answered Questions

Element is not clickable at point (x,y)

  • 2016-08-03 12:37:08
  • Kevin Janke
  • 126 View
  • 3 Score
  • 3 Answer
  • Tags:   java selenium

3 Answered Questions

[SOLVED] Element is not clickable at point using chrome driver

Sponsored Content