1. Manipulate the scroll bar to the element position of the currently visible view
webelement element = Dr.findelement (By.id ("4")); ((Javascriptexecutor) DR). Executescript ("Arguments[0].scrollintoview (true);", Element);
Or
New Actions (DR); A.movetoelement (Dr.findelement (By.id ("4")). Perform ();
2. Operate the scroll bar to the bottom or top of the
New Actions (DR); A.sendkeys (Keys.page_down). Perform (); Try { Thread.Sleep (+); Catch (interruptedexception e) { // TODO auto-generated catch block E.printstacktrace (); } A.sendkeys (KEYS.PAGE_UP). Perform ();
Or
String js = "document.documentelement.scrolltop=10000"; ((Javascriptexecutor) DR). Executescript (JS); = "Document.documentelement.scrolltop=0"; ((Javascriptexecutor) DR). Executescript (JS1);
Or
String js = "document.getElementById (\" Su\ "). scrolltop=10000"; ((Javascriptexecutor) DR). Executescript (JS); = "document.getElementById (\" Su\ "). Scrolltop=0"; ((Javascriptexecutor) DR). Executescript (JS1);
Selenium several ways to manipulate the scroll bar