nhoyti
nhoyti

Reputation: 1997

how to access scroll bar inside the div using protractor for e2e

im currently writing an e2e script however, im having issues accessing an element when the a div overflows and scrollbar within the div is being activated.

Inside the form, i need to access the scroll down inside the div of the request travel form.

enter image description here

I tried using:

 browser.executeScript("window.scrollTo(0,10000);").then(callback);

However, the scrollbar that it access is the browser itself not the div i intended to scroll down.

Any leads or suggestion is greatly appreciate.

Thanks!

Upvotes: 1

Views: 2312

Answers (1)

Yash Jagdale
Yash Jagdale

Reputation: 1508

I had same issue with my application. There is no direct way using which you can scroll inside scrollbar but I achieved it using javacript executor.

Option 1:-
You can select element till which you wanted to scroll.
example:- (replace with your actual identifier)

browser.executeScript('arguments[0].scrollIntoView(true)', <yourelement>.getWebElement());

Option 2:-
Find the identifier of element on which scrollbar is applied and use below code.

var objDiv = document.getElementById("divExample");
objDiv.scrollTop = objDiv.scrollHeight;

let me know if still facing issue.

Upvotes: 1

Related Questions