Using selenium with java, I need to test a \"Back to top\" button, so what I did is to scroll page down until \"Back to top\" button is shown (as it is shown when scrolled 25% o
Louis' answer works, but is not fully cross-browser compatible, as Internet Explorer does not support window.scrollY. I recommend using window.pageYOffset instead - this returns the same value but is cross-browser compatible.
Source: https://developer.mozilla.org/en-US/docs/Web/API/Window/scrollY
Here is the above code block with the modified code:
JavascriptExecutor executor = (JavascriptExecutor) driver;
Long value = (Long) executor.executeScript("return window.pageYOffset;");
Also, syntax for Ruby (what I use for my current position, assuming as before that the driver instance is accessible through the variable name, 'driver'):
driver.execute_script('return window.pageYOffset;')