0

I need to emulate mouse moving and scroll down with mouse wheel in Java. I've found following solution:

Robot robot = new Robot();
robot.mouseMove(1850, 300);
robot.mouseWheel(10);

But this code perform moving and scrolling with real mouse. I use Jenkins to run 5 browsers on a machine. And this solutions doesnt work becouse one browser may overlay other. There is Actions class. In this class there're methods for scrolling to WebElements that using programmatically created mouse. Is it possible to emulate scrolling with mouse wheel in similar to Actions class way or something other?

  • Look at this one https://stackoverflow.com/questions/25363023/mouse-scroll-down-using-selenium-webdriver-a-k-a-selenium-2-0-java – Daniil Volkov Apr 06 '18 at 13:06
  • Thanks. Do you know how this JS-code "window.scrollTo(0,document.body.scrollHeight);" do scrolling? Is it emulate mouse wheel or do scrolling in other way? – Сергей Чевычелов Apr 06 '18 at 13:17
  • Specific issue "this solutions doesnt work becouse one browser may overlay other" could also be resolved by maximizing browser window on top of which you are moving the mouse, and making sure you switch to it before any mouse operations (so you are guaranteed to hit the right window). But you've got to be more specific about the elements you are trying to access and why it doesn't work now, hard to answer with this amount of details. – timbre timbre Apr 06 '18 at 15:19

0 Answers0