1

hoping someone can help me here, I have a website that takes a while to load, in order to successfully load all images on the page, I need to keep scrolling down while the page is still loading. I can not wait for the page to load first and then scroll.

I am aware of using the following to scroll to the bottom of the page, I have tried running this on a separate thread in a loop prior to and after getting the url with driver.get("SITE HERE"); to try and keep the page scrolling to the bottom until it has fully loaded.

JavascriptExecutor js = ((JavascriptExecutor) driver);
js.executeScript("window.scrollTo(0, document.body.scrollHeight)");

This has not worked and I am at a loss on how to get selenium to scroll a page while it is still in the process of loading.

1 Answer 1

0

The webdriver get(String url) command states in its documentation that it will block until the page is loaded. If you call that you won't be able to try to scroll. I haven't ever tried it myself but you could try to load the page via JavaScript instead but it's not a great practice as you could very well end up with issues regarding the script context if you tried to loop in the same script call and could have timing issues if in a different script call (from the web driver). My first recommendation would be to talk to the page developer and make it so that scrolling after page load works correctly

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.