1
0
mirror of https://github.com/jbranchaud/til synced 2026-01-03 15:18:01 +00:00
Files
til/ruby/scroll-to-top-of-page-with-capybara.md
2017-11-02 11:14:12 -05:00

13 lines
399 B
Markdown

# Scroll To Top Of Page With Capybara
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:
```ruby
page.execute_script "window.scrollTo(0,0)"
```
This will scroll to `0,0` which is the top-most, left-most corner of the
browser.