During a browser-based Capybara test, you may get partially scrolled down in
the page which can obscure or overlay DOM elements. A sure-fire way to
scroll back to the top is by executing the following line of JavaScript:

page.execute_script "window.scrollTo(0,0)"

This will scroll to 0,0 which is the top-most, left-most corner of the
browser.

Today I Learned is an open-source project by
Hashrocket
that exists to catalogue the sharing & accumulation of knowledge
as it happens day-to-day. Posts have a 200-word limit, and
posting is open to any Rocketeer as well as selected friends of
Hashrocket. We hope you enjoy learning along with us.