1

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.

1 Answer 1

3

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.

Sign up to request clarification or add additional context in comments.

1 Comment

Just to clarify because I found this a little confusing until I did some investigation. the "$('#paste_code') part of that line is the name of the element that you want to scroll through.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.