Scrolling using Selenium WebDriver with Java

前端 未结 8 2119
长情又很酷
长情又很酷 2020-12-25 08:47

I am using Selenium WebDriver to automate my browser tests. My browser header is floating and is always present irrespective of the browser scroll.

<
8条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-25 09:42

    Scroll to top can be done:

    private void scrollToTop() {
        JavascriptExecutor js = (JavascriptExecutor) webDriver;
        js.executeScript("window.scrollTo(0, 0);");
    }
    

提交回复
热议问题