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

Inherits:
Object
  • Object
show all
Defined in:
rb/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.



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

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.



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

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