Scrolling using Selenium WebDriver with Java

前端 未结 8 2144
长情又很酷
长情又很酷 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:51

    If you want to scroll on the firefox window using selenium webdriver, one of the way is to use javaScript in the java code, The javeScript code to scroll down is as follows:

    JavascriptExecutor js = (JavascriptExecutor)driver;
                        js.executeScript("window.scrollTo(0,Math.max(document.documentElement.scrollHeight," +
                        "document.body.scrollHeight,document.documentElement.clientHeight));");
    

提交回复
热议问题