Debugging “Element is not clickable at point” error

后端 未结 30 2603
余生分开走
余生分开走 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:27

    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)')
    }
    

提交回复
热议问题