Scrolling in Selenium

null

Introduction

Most of the solutions will tell you to inject a JavaScript to do this. However, trick is to use keyboard buttons.

Here’s an example in ruby:

# Lets grab the body on which will be sending keys
bodyElement = @driver.find_element(css: "body")
(1..5).each do
# method sample is defined in rails, you can try :page_up only if not on rails
bodyElement.send_keys([:page_up,:page_down].sample)
sleep 2.seconds
end 


Tell your network!

1 Comments

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>