1
0
mirror of https://github.com/jbranchaud/til synced 2026-01-07 00:58:02 +00:00

Add Scroll To Top Of Page With Capybara as ruby til

This commit is contained in:
jbranchaud
2017-11-02 11:14:12 -05:00
parent c4caf870f0
commit 685d386dfc
2 changed files with 14 additions and 1 deletions

View File

@@ -0,0 +1,12 @@
# 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.