Class: Watir::Browser::Scroll
- Inherits:
-
Object
- Object
- Watir::Browser::Scroll
- Defined in:
- lib/browser_scroll/browser/scroll.rb
Instance Method Summary collapse
- #bottom ⇒ Object
- #by(left, top) ⇒ Object
-
#initialize(browser) ⇒ Scroll
constructor
A new instance of Scroll.
- #middle ⇒ Object
- #to(param = nil) ⇒ Object
- #top ⇒ Object
Constructor Details
#initialize(browser) ⇒ Scroll
Returns a new instance of Scroll.
4 5 6 |
# File 'lib/browser_scroll/browser/scroll.rb', line 4 def initialize(browser) @browser = browser end |
Instance Method Details
#bottom ⇒ Object
27 28 29 30 |
# File 'lib/browser_scroll/browser/scroll.rb', line 27 def bottom execute('window.scrollTo(0, document.body.scrollHeight);') self end |
#by(left, top) ⇒ Object
39 40 41 42 43 44 45 |
# File 'lib/browser_scroll/browser/scroll.rb', line 39 def by(left, top) execute( 'window.scrollBy(arguments[0], arguments[1]);', Integer(left), Integer(top) ) self end |
#middle ⇒ Object
32 33 34 35 36 37 |
# File 'lib/browser_scroll/browser/scroll.rb', line 32 def middle execute( 'window.scrollTo(window.outerWidth / 2, window.outerHeight / 2);' ) self end |
#to(param = nil) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/browser_scroll/browser/scroll.rb', line 8 def to(param = nil) if !param.nil? && param.is_a?(Array) unless param.is_a?(Array) raise ArgumentError, "Unable to scroll to: #{param}." end execute( 'window.scrollTo(arguments[0], arguments[1]);', Integer(param[0]), Integer(param[1]) ) end self end |
#top ⇒ Object
22 23 24 25 |
# File 'lib/browser_scroll/browser/scroll.rb', line 22 def top execute('window.scrollTo(0, 0);') self end |