简体   繁体   中英

JavaScript scroll over element works in Chrome but not in IE11

I'm writing an e2e test with selenium C#

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). 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:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM