[英]JavaScript scroll over element works in Chrome but not in IE11
I'm writing an e2e test with selenium C# 我正在用硒C#编写e2e测试
I need to scroll to the bottom of a kendo-grid scrollbar element (scrolling any other element like grid body does not seem to work). 我需要滚动到kendo-grid滚动条元素的底部(滚动其他任何元素,例如网格体似乎都行不通)。 The code that does that is:
这样做的代码是:
$('div.k-scrollbar-vertical')[0].scrollTo(0,12000)
Works fine in Chrome console and via IJavaScriptExecutor
in C#, but trying it in IE11 raises an error: 在Chrome控制台中以及通过C#中的
IJavaScriptExecutor
可以IJavaScriptExecutor
,但是在IE11中尝试会出现错误:
Object doesn't support property or method 'scrollTo'
Is there any way I can make it compatible to both browsers or any workaround? 有什么办法可以使其兼容两种浏览器或任何替代方法?
Why not use the more supported mechanism? 为什么不使用更多受支持的机制?
const o = document.querySelector('div.k-scrollbar-vertical')
o.scrollTop = o.scrollHeight
And if const
is not supported in your version, you can use var
如果您的版本不支持
const
则可以使用var
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.