Selenium, how do you check scroll position

后端 未结 3 597
我寻月下人不归
我寻月下人不归 2021-02-07 11:00

Using selenium with java, I need to test a \"Back to top\" button, so what I did is to scroll page down until \"Back to top\" button is shown (as it is shown when scrolled 25% o

3条回答
  •  臣服心动
    2021-02-07 11:26

    if necessary, find the position scrolled to one specify div, use this code:

    JavascriptExecutor executor = (JavascriptExecutor) driver;
    Long value = (Long) executor.executeScript("return document.getElementById('container').scrollTop;");
    

提交回复
热议问题