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;");

}

1 comment:

harikasri.blogspot.com said...


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