如何使用 e2e 的量角器访问 div 内的滚动条 [英] how to access scroll bar inside the div using protractor for e2e
问题描述
我目前正在编写 e2e 脚本,但是当 div 溢出并且 div 中的滚动条被激活时,我在访问元素时遇到问题.
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.
在表单内,我需要在请求旅行表单的 div 内向下滚动.
Inside the form, i need to access the scroll down inside the div of the request travel form.
我尝试使用:
browser.executeScript("window.scrollTo(0,10000);").then(callback);
但是,它访问的滚动条是浏览器本身,而不是我打算向下滚动的 div.
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.
谢谢!
推荐答案
我的应用程序遇到了同样的问题.没有直接的方法可以在滚动条内滚动,但我使用 javacript 执行器实现了它.
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.
选项 1:-
您可以选择要滚动的元素.
示例:-(替换为您的实际标识符)
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());
选项 2:-
找到应用滚动条的元素的标识符并使用以下代码.
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.
这篇关于如何使用 e2e 的量角器访问 div 内的滚动条的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!