I came up in a scenario where I have floating button to identify. There is two buttons, Save and Cancel. When I am on top of the page buttons are like in a floating panel and once I scroll down and reach the bottom of the page then button will be fixed. So both cases I have two different identifier to identify the buttons. I am using the below code to scroll down.

JavascriptExecutor jse = (JavascriptExecutor)driver;
                jse.executeScript("window.scrollBy(0,250)", "");

My question is, when I scroll down, how to know I reached the end of the page or not? Because I cannot scroll like unlimited time right? Once I reached the bottom of the page I can stop scrolling and check for the fixed button element.

1 Answer 1


You can scroll to the end of the page using JavaScript as pointed out in this SO answer. Here is the code snippet:


This works fine unless you have content load as you scroll down (i.e. lazy loading). If that is the case, I would scroll to the bottom until a condition is met. This condition could be your "floating" element is Displayed.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.