Module: Appium::Core::Base::SearchContext

Included in:
Driver
Defined in:
lib/appium_lib_core/common/base/search_context.rb

Constant Summary collapse

FINDERS =

referenced: ::Selenium::WebDriver::SearchContext

::Selenium::WebDriver::SearchContext::FINDERS.merge(accessibility_id: 'accessibility id')

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.add_finders(finders) ⇒ Object



9
10
11
# File 'lib/appium_lib_core/common/base/search_context.rb', line 9

def self.add_finders(finders)
  FINDERS.merge!(finders)
end

Instance Method Details

#find_element(how, what) ⇒ Element #find_element(opts) ⇒ Element

Find the first element matching the given arguments

Examples:

Find element with accessibility id

find_elements :accessibility_id, 'Animation'
find_elements :accessibility_id, 'Animation'

Overloads:

  • #find_element(how, what) ⇒ Element

    Parameters:

    • how (Symbol, String)

      The method to find the element by

    • what (String)

      The locator to use

  • #find_element(opts) ⇒ Element

    Parameters:

    • opts (Hash)

      Find options

    Options Hash (opts):

    • :how (Symbol)

      Key named after the method to find the element by, containing the locator

Returns:

  • (Element)

Raises:



30
31
32
33
34
35
36
37
38
# File 'lib/appium_lib_core/common/base/search_context.rb', line 30

def find_element(*args)
  how, what = extract_args(args)
  by = _set_by_from_finders(how)
  begin
    bridge.find_element_by by, what.to_s, ref
  rescue Selenium::WebDriver::Error::TimeOutError
    raise Selenium::WebDriver::Error::NoSuchElementError
  end
end

#find_elements(*args) ⇒ Object

Find all elements matching the given arguments

See Also:



45
46
47
48
49
50
51
52
53
# File 'lib/appium_lib_core/common/base/search_context.rb', line 45

def find_elements(*args)
  how, what = extract_args(args)
  by = _set_by_from_finders(how)
  begin
    bridge.find_elements_by by, what.to_s, ref
  rescue Selenium::WebDriver::Error::TimeOutError
    raise Selenium::WebDriver::Error::NoSuchElementError
  end
end