123456789_123456789_123456789_123456789_123456789_

Class: Selenium::WebDriver::Interactions::Scroll Private

Do not use. This class is for internal use only.
Relationships & Source Files
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
self, Interaction
Instance Chain:
self, Interaction
Inherits: Selenium::WebDriver::Interactions::Interaction
Defined in: rb/lib/selenium/webdriver/common/interactions/scroll.rb

Overview

Action related to scrolling a wheel.

Class Method Summary

Instance Attribute Summary

Interaction - Inherited

Instance Method Summary

Interaction - Inherited

Constructor Details

.new(source:, origin: :viewport, duration: 0.25, **opts) ⇒ Scroll

Raises:

  • (ArgumentError)
[ GitHub ]

  
# File 'rb/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

Instance Method Details

#assert_source(source)

Raises:

  • (TypeError)
[ GitHub ]

  
# File 'rb/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

[ GitHub ]

  
# File 'rb/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