javascript - How to scroll smoothly with Selenium WebDriver and/or Sikuli in Java -
as part of test suite measuring fps web application need perform smooth scroll of web page. is, same smoothness when user grabs scroll bar , moves mouse.
so far have tried using simulating key presses sikuli, i.e. pressing arrow up/down keys multiple times scroll whole page. have tried using javascript approach:
public void scrollsmooth(int durationofscroll){ long timewhenstarting = system.currenttimemillis() / 1000l; while (system.currenttimemillis() / 1000l - timewhenstarting < durationofscroll) { ((javascriptexecutor) driver).executescript("window.scrollby(0,10)", ""); } }
both these approaches fails fulfill purpose, both generate step-by-step scroll, not suitable when simultaneously want measure fps (e.g. smoothnes of page when scrolling).
the solution lot more simple expected. instead of using time-based condition loop tried following:
public void scrollsmooth(){ for(int i=0;i<6000;i++) { ((javascriptexecutor) driver).executescript("window.scrollby(0,1)", ""); } }
this works well, small downside cannot specify length (in time) of scroll, actual pixels scrolled.
Comments
Post a Comment