Checkout our demo site to practice selenium https://magento.softwaretestingboard.com/

0 like 0 dislike
376 views
by The go-to Tester (324 points)

How to Scroll Up Web Page In Selenium Webdriver?

Thank You

1 Answer

0 like 0 dislike
by The go-to Tester (181 points)
selected by
 
Best answer

You can use JavaScript to scroll the page in Selenium WebDriver.

 

((JavascriptExecutor) driver).executeScript("scroll(0,300)");
 
Here, (0,300) are the horizontal and vertical distances respectively. You can put the distance as per your requirement.
 
You can try this Firefox add-on, MeasureIt to get perfect distance.
 
hope that helps.
by The go-to Tester (324 points)
and what about left to right and right to left scroll?
by The go-to Tester (181 points)
As per the answer, in (0,300) the first value is horizontal value, so changing that will help you scroll horizontally / left or right and 300 is vertical distance, So changing that value will help you scroll up and down.

Hope I answered it.


This site is for software testing professionals, where you can ask all your questions and get answers from 1300+ masters of the profession. Click here to submit yours now!

1.4k questions

1.6k answers

866 comments

1.9k users

...