Debugging “Element is not clickable at point” error

后端 未结 30 2123
余生分开走
余生分开走 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.

提交回复
热议问题