Selenium operation scroll bar

//Move to the "top" of the element object and align it with the "top" of the current window
((JavascriptExecutor) driver).executeScript("arguments[0].scrollIntoView();", element);
((JavascriptExecutor) driver). executeScript("arguments[0].scrollIntoView(true);", element);

//Move to the "bottom" of the element element object and align it with the "bottom" of the current window
((JavascriptExecutor) driver).executeScript("arguments[0].scrollIntoView(false);", element);

//Move to the bottom of the page
((JavascriptExecutor) driver).executeScript("window.scrollTo(0, document.body.scrollHeight)");

//Move to the specified coordinates (move relative to the current coordinates)
((JavascriptExecutor) driver).executeScript("window.scrollBy(0, 700)");
Thread.sleep(3000);
//Combined with the above scrollBy statement, Equivalent to moving to 700+800=1600 pixel position
((JavascriptExecutor) driver).executeScript("window.scrollBy(0, 800)");

//Move to the absolute position coordinates of the window, move to the 1600 pixel position of the vertical coordinate as follows
((JavascriptExecutor) driver).executeScript("window.scrollTo(0, 1600)");
Thread.sleep(3000);
//Combined with the above The scrollTo statement still moves to the vertical coordinate position of 1200 pixels
((JavascriptExecutor) driver).executeScript("window.scrollTo(0, 1200)");

Guess you like

Origin blog.csdn.net/weixin_43651674/article/details/87806790