class Selenium::WebDriver::Interactions::Scroll

Action related to scrolling a wheel.

@api private

Public Class Methods

new(source:, origin: :viewport, duration: 0.25, **opts) click to toggle source
# File lib/selenium/webdriver/common/interactions/scroll.rb, line 30
def initialize(source:, origin: :viewport, duration: 0.25, **opts)
  super(source)
  @type = :scroll
  @duration = duration * 1000
  @origin = origin
  @x_offset = opts.delete(:x) || 0
  @y_offset = opts.delete(:y) || 0
  @delta_x = opts.delete(:delta_x) || 0
  @delta_y = opts.delete(:delta_y) || 0

  raise ArgumentError, "Invalid arguments: #{opts.keys}" unless opts.empty?
end

Public Instance Methods

assert_source(source) click to toggle source
# File lib/selenium/webdriver/common/interactions/scroll.rb, line 43
def assert_source(source)
  raise TypeError, "#{source.type} is not a valid input type" unless source.is_a? WheelInput
end
encode() click to toggle source
# File lib/selenium/webdriver/common/interactions/scroll.rb, line 47
def encode
  {'type' => type.to_s,
   'duration' => @duration.to_i,
   'x' => @x_offset,
   'y' => @y_offset,
   'deltaX' => @delta_x,
   'deltaY' => @delta_y,
   'origin' => @origin.is_a?(Element) ? @origin : @origin.to_s}
end