How do I automate scrollbar of any website

41 views
Skip to first unread message

Swapnil Shrivastava

unread,
Sep 25, 2016, 3:40:02 AM9/25/16
to Selenium Users
How do I automate scrollbar of any website .I tried using Actions class but I dont see the xpath of webelement scroll bar.

Andreas Tolfsen

unread,
Sep 25, 2016, 6:31:47 AM9/25/16
to seleniu...@googlegroups.com, Swapnil Shrivastava
Swapnil Shrivastava <swapnilshr...@gmail.com> writes:

> How do I automate scrollbar of any website .I tried using Actions
> class but I dont see the xpath of webelement scroll bar.

WebDriver does not do automation of native OS widgets. It concerns
itself strictly with web content.

Normally you won’t have to interact with the scroll bar as there are
enough primitives to otherwise scroll the document. Before any
interaction using the do-as-I-mean APIs (click, send keys, &c.)
scrolling will happen implicitly, i.e. element.scrollIntoView will be
called.

Shubham Agarwal

unread,
Sep 26, 2016, 5:20:24 AM9/26/16
to Selenium Users
If you want to automate the scrollbar then surely you will able to find the xpath of that , and if you just want to perform the scrolling operations then you can do like this :

For Scroll Down :

WebDriver driver = new FirefoxDriver();
JavascriptExecutor jse = (JavascriptExecutor)driver;
jse.executeScript("window.scrollBy(0,250)", "");
For Scroll Up:
jse.executeScript("window.scrollBy(0,-250)", "");
OR,
jse.executeScript("scroll(0, -250);");
Reply all
Reply to author
Forward
0 new messages