how to access scroll bar inside the div using prot

2019-07-29 04:53发布

问题:

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.

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!

回答1:

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.