How to scroll the webpage to the top of the page.
I know scrolling the page to the bottom is:
window.scrollTo(0,document.body.scrollHeight)
just like that is it possible to scroll the page to the top
How to scroll the webpage to the top of the page.
I know scrolling the page to the bottom is:
window.scrollTo(0,document.body.scrollHeight)
just like that is it possible to scroll the page to the top
This solution also works correctly, I've checked it:
simple way for the top :
webDriver.FindElement(By.TagName("body")).SendKeys(Keys.Home);
and for the bottom:webDriver.FindElement(By.TagName("body")).SendKeys(Keys.End);
yes you can try as below
Way one - Scrolling to bottom of a page
Way two - Scrolling to an element on a page
Way 3 -Scrolling by coordinates
To scroll to the top of the page, just scroll to the
0, 0
:Or, as an alternative option, you can scroll into view of the
header
element (or some other element on top):To scroll to the top of the page
To scroll to the end of the page
Use action class, as some UI frameworks don't work well with JavaScript scrollTO