Issue
I am trying to load a page ins selenium. After that, I need to scroll to the end of the page.
For that, I am trying this
import org.openqa.selenium.JavascriptExecutor
driver.get(<My URL>)
JavascriptExecutor js = (JavascriptExecutor) driver
js.executeScript("window.scrollBy(0,document.body.scrollHeight)")
But it is not working and showing syntax error
Solution
to scroll all the way down, you can invoke execute_script
like below:
driver.execute_script("var scrollingElement = (document.scrollingElement || document.body);scrollingElement.scrollTop = scrollingElement.scrollHeight;")
Answered By - cruisepandey
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.