Debugging “Element is not clickable at point” error

后端 未结 30 1975
余生分开走
余生分开走 2020-11-21 23:55

I see this only in Chrome.

The full error message reads:

\"org.openqa.selenium.WebDriverException: Element is not clickable at point (411, 675

相关标签:
30条回答
  • 2020-11-22 00:34

    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.

    0 讨论(0)
  • 2020-11-22 00:35

    I 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" ...
    
    0 讨论(0)
  • 2020-11-22 00:36

    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-

    0 讨论(0)
  • 2020-11-22 00:36

    I have seen this in the situation when the selenium driven Chrome window was opened too small. The element to be clicked on was out of the viewport and therefore it was failing.

    That sounds logical... real user would have to either resize the window or scroll so that it is possible to see the element and in fact click on it.

    After instructing the selenium driver to set the window size appropriately this issues went away for me. The webdriver API is decribed here.

    0 讨论(0)
  • 2020-11-22 00:37

    When using Protractor this helped me:

    var elm = element(by.css('.your-css-class'));
    browser.executeScript("arguments[0].scrollIntoView();", elm.getWebElement());
    elm.click();
    
    0 讨论(0)
  • 2020-11-22 00:39

    Maybe it's not really clean solution but it works:

    try:
        el.click()
    except WebDriverException as e:
        if 'Element is not clickable at point' in e.msg:
            self.browser.execute_script(
                '$("{sel}").click()'.format(sel=el_selector)
            )
        else:
            raise
    
    0 讨论(0)
提交回复
热议问题