1
0
mirror of https://github.com/jbranchaud/til synced 2026-01-02 22:58:01 +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

@@ -10,7 +10,7 @@ smart people at [Hashrocket](http://hashrocket.com/).
For a steady stream of TILs from a variety of rocketeers, checkout
[til.hashrocket.com](https://til.hashrocket.com/).
_580 TILs and counting..._
_581 TILs and counting..._
---
@@ -461,6 +461,7 @@ _580 TILs and counting..._
- [Returning With Sequel](ruby/returning-with-sequel.md)
- [Running A Single MiniTest Example](ruby/running-a-single-minitest-example.md)
- [Safe Navigation Operator](ruby/safe-navigation-operator.md)
- [Scroll To Top Of Page With Capybara](ruby/scroll-to-top-of-page-with-capybara.md)
- [Set RVM Default Ruby](ruby/set-rvm-default-ruby.md)
- [Show Public Methods With Pry](ruby/show-public-methods-with-pry.md)
- [Squeeze Out The Extra Space](ruby/squeeze-out-the-extra-space.md)

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.