Scroll Up, Down or Anywhere on a Page

Scrolling on any web page is required almost always. You may use below snippets to do scrolling in any direction you need.
  1. JavascriptExecutor jsx = (JavascriptExecutor) driver;  
  2.   
  3. //Vertical scroll - down by 100 pixels  
  4. jsx.executeScript("window.scrollBy(0,100)""");  
  5.   
  6. //Vertical scroll - up by 55 pixels (number should be in negative)  
  7. jsx.executeScript("window.scrollBy(0,-55)""");  
  8.   
  9. //Horizontal scroll - right by 20 pixels  
  10. jsx.executeScript("window.scrollBy(20,0)""");  
  11.   
  12. //Horizontal scroll - left by 95 pixels (number should be negative)  
  13. jsx.executeScript("window.scrollBy(-95,0)""");