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:
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