Reputation: 355
I've been searching for a while to find a way to scroll in an element using selenium. I'm already able to scroll up and down the web page, but I haven't found a way to use the scroll bar inside an element. I was wondering if anyone else knew how to do it.
Upvotes: 1
Views: 988
Reputation: 359
You can use execute_script
, for example, if we go to a random pastebin link (https://pastebin.com/en0f652r) and use the code below, it will scroll down the pasted code window.
driver.execute_script("$('#paste_code').animate({scrollTop: '100px'})")
Replace "#paste_code" with the scroll bar element you are wishing to scroll.
Upvotes: 3