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

Inherits:
Interaction
  • Object
show all
Defined in:
lib/selenium/webdriver/common/interactions/scroll.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Action related to scrolling a wheel.

Instance Attribute Summary

Attributes inherited from Interaction

#type

Instance Method Summary collapse

Constructor Details

#initialize(source:, x: 0, y: 0, delta_x: 0, delta_y: 0, origin: :viewport, duration: 0.25) ⇒ Scroll

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Scroll.



30
31
32
33
34
35
36
37
38
39
# File 'lib/selenium/webdriver/common/interactions/scroll.rb', line 30

def initialize(source:, x: 0, y: 0, delta_x: 0, delta_y: 0, origin: :viewport, duration: 0.25)
  super(source)
  @type = :scroll
  @duration = duration * 1000
  @origin = origin
  @x_offset = x
  @y_offset = y
  @delta_x = delta_x
  @delta_y = delta_y
end

Instance Method Details

#assert_source(source) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Raises:

  • (TypeError)


41
42
43
# File 'lib/selenium/webdriver/common/interactions/scroll.rb', line 41

def assert_source(source)
  raise TypeError, "#{source.type} is not a valid input type" unless source.is_a? WheelInput
end

#encodeObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



45
46
47
48
49
50
51
52
53
# File 'lib/selenium/webdriver/common/interactions/scroll.rb', line 45

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