A scrollbar lets you move around the screen if the page does not fit the visible area of the screen, contrary to Selenium Webdriver in certain webpages the elements become visible only when you have scrolled through them, in such cases scrolling becomes necessary.
Now, there are multiple ways of scrolling through a webpage, which will be explained here by the means of scroll down method and same can be implemented for scroll up with minimal changes. There are 3 methods for scrolling :-
Scroll up/down by pixel
The parameters x-pixel, y-pixel here represents the pixels on the screen, x-pixel would move right if the value is negative and vice versa, y-pixel moves up if the value is negative and down if it is more positive.
To scroll up, the pixel could be adjusted to have incremental setup.
Scroll up/down by the visibility of the element
The parameter “argument” here represents first index of that page starting at 0.
Scroll down to the bottom of page/ up to top of page
The parameter "document.body.scrollHeight" here represents the complete height of the webpage.
To Scroll up put - documnent.body.scrollHeight and to scroll down document.body.scrollHeight.
If you wish to Learn Selenium visit this Selenium Webdriver Tutorial by Intellipaat.