mirror of
https://github.com/jbranchaud/til
synced 2026-01-03 23:28:02 +00:00
Add Scroll To Top Of Page With Capybara as ruby til
This commit is contained in:
@@ -10,7 +10,7 @@ smart people at [Hashrocket](http://hashrocket.com/).
|
|||||||
For a steady stream of TILs from a variety of rocketeers, checkout
|
For a steady stream of TILs from a variety of rocketeers, checkout
|
||||||
[til.hashrocket.com](https://til.hashrocket.com/).
|
[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)
|
- [Returning With Sequel](ruby/returning-with-sequel.md)
|
||||||
- [Running A Single MiniTest Example](ruby/running-a-single-minitest-example.md)
|
- [Running A Single MiniTest Example](ruby/running-a-single-minitest-example.md)
|
||||||
- [Safe Navigation Operator](ruby/safe-navigation-operator.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)
|
- [Set RVM Default Ruby](ruby/set-rvm-default-ruby.md)
|
||||||
- [Show Public Methods With Pry](ruby/show-public-methods-with-pry.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)
|
- [Squeeze Out The Extra Space](ruby/squeeze-out-the-extra-space.md)
|
||||||
|
|||||||
12
ruby/scroll-to-top-of-page-with-capybara.md
Normal file
12
ruby/scroll-to-top-of-page-with-capybara.md
Normal 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.
|
||||||
Reference in New Issue
Block a user