Class: Selenium::WebDriver::Support::RelativeLocator Private

Inherits:
Object
  • Object
show all
Defined in:
lib/selenium/webdriver/support/relative_locator.rb

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.

Constant Summary collapse

KEYS =

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

%w[above below left right near distance].freeze

Instance Method Summary collapse

Constructor Details

#initialize(locator) ⇒ RelativeLocator

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 RelativeLocator.



30
31
32
# File 'lib/selenium/webdriver/support/relative_locator.rb', line 30

def initialize(locator)
  @filters, @root = locator.partition { |how, _| KEYS.include?(how) }.map(&:to_h)
end

Instance Method Details

#as_jsonObject

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.



34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/selenium/webdriver/support/relative_locator.rb', line 34

def as_json
  {
    relative: {
      root: @root,
      filters: @filters.map do |kind, filter|
        {
          kind: kind,
          args: [filter]
        }
      end
    }
  }
end