Search This Blog

February 23, 2017

Selenium: How to get the scroll position?

I have one test case I need to check the scroll position. If I click the url on the page, it will scroll down to the bottom of the page.

After looking into this interesting feature, here is the code I use in different browsers.

Before clicking the url, the value will be 0. After clicking the url , the value will be different.

public long GetScrollPosition()
{
  IJavaScriptExecutor executor = (IJavaScriptExecutor)_driver;
  return (long)executor.ExecuteScript("return window.pageYOffset;");

}

3 comments:

hellanadam said...

You have provided an nice article, Thank you very much for this one. And i hope this will be useful for many people.. and i am waiting for your next post keep on updating these kinds of knowledgeable things...
Mobile App Development Company

akhila priya said...

Nice information thank you,if you want more information please visit our link selenium Online Training Hyderabad

harikasri.blogspot.com said...


Amazing write-up! , i Request you to write more blogs like this Blockchain Online course Bangalore