module Selenium::WebDriver::WheelActions
def default_scroll_duration
def default_scroll_duration @default_scroll_duration ||= @duration / 1000.0 # convert ms to seconds end
def scroll(**opts)
def scroll(**opts) opts[:duration] = default_scroll_duration wheel = wheel_input(opts.delete(:device)) wheel.create_scroll(**opts) tick(wheel) self end
def scroll_by(delta_x, delta_y, device: nil)
-
(Selenium::WebDriver::WheelActions)
- A self reference.
Parameters:
-
delta_y
(Integer
) -- Distance along Y axis to scroll using the wheel. A negative value scrolls up. -
delta_x
(Integer
) -- Distance along X axis to scroll using the wheel. A negative value scrolls left.
Other tags:
- Example: Scroll viewport by a specified amount -
def scroll_by(delta_x, delta_y, device: nil) scroll(delta_x: delta_x, delta_y: delta_y, device: device) end
def scroll_from(scroll_origin, delta_x, delta_y, device: nil)
-
(Error::MoveTargetOutOfBoundsError)
- If the origin with offset is outside the viewport.
Returns:
-
(Selenium::WebDriver::WheelActions)
- A self reference.
Parameters:
-
delta_y
(Integer
) -- Distance along Y axis to scroll using the wheel. A negative value scrolls up. -
delta_x
(Integer
) -- Distance along X axis to scroll using the wheel. A negative value scrolls left. -
scroll_origin
(ScrollOrigin
) -- Where scroll originates (viewport or element center) plus provided offsets.
Other tags:
- Example: Scroll viewport by a specified amount with an offset -
Example: Scroll from element by a specified amount with an offset -
Example: Scroll from element by a specified amount -
def scroll_from(scroll_origin, delta_x, delta_y, device: nil) raise TypeError, "#{scroll_origin.inspect} isn't a valid ScrollOrigin" unless scroll_origin.is_a?(ScrollOrigin) scroll(x: scroll_origin.x_offset, y: scroll_origin.y_offset, delta_x: delta_x, delta_y: delta_y, origin: scroll_origin.origin, device: device) end
def scroll_to(element, device: nil)
-
(Selenium::WebDriver::WheelActions)
- A self reference.
Parameters:
-
device
(Object
) -- Which device to use to scroll -
element
(Object
) -- Which element to scroll into the viewport.
Other tags:
- Example: Scroll to element -
def scroll_to(element, device: nil) scroll(origin: element, device: device) end
def wheel_input(name = nil)
def wheel_input(name = nil) device(name: name, type: Interactions::WHEEL) || add_wheel_input('wheel') end