Skip to content

Commit 685d386

Browse files
committed
Add Scroll To Top Of Page With Capybara as ruby til
1 parent c4caf87 commit 685d386

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ smart people at [Hashrocket](http://hashrocket.com/).
1010
For a steady stream of TILs from a variety of rocketeers, checkout
1111
[til.hashrocket.com](https://til.hashrocket.com/).
1212

13-
_580 TILs and counting..._
13+
_581 TILs and counting..._
1414

1515
---
1616

@@ -461,6 +461,7 @@ _580 TILs and counting..._
461461
- [Returning With Sequel](ruby/returning-with-sequel.md)
462462
- [Running A Single MiniTest Example](ruby/running-a-single-minitest-example.md)
463463
- [Safe Navigation Operator](ruby/safe-navigation-operator.md)
464+
- [Scroll To Top Of Page With Capybara](ruby/scroll-to-top-of-page-with-capybara.md)
464465
- [Set RVM Default Ruby](ruby/set-rvm-default-ruby.md)
465466
- [Show Public Methods With Pry](ruby/show-public-methods-with-pry.md)
466467
- [Squeeze Out The Extra Space](ruby/squeeze-out-the-extra-space.md)
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Scroll To Top Of Page With Capybara
2+
3+
During a browser-based Capybara test, you may get partially scrolled down in
4+
the page which can obscure or overlay DOM elements. A sure-fire way to
5+
scroll back to the top is by executing the following line of JavaScript:
6+
7+
```ruby
8+
page.execute_script "window.scrollTo(0,0)"
9+
```
10+
11+
This will scroll to `0,0` which is the top-most, left-most corner of the
12+
browser.

0 commit comments

Comments
 (0)