Module: Appium::Core::Base::SearchContext
Constant Summary collapse
- FINDERS =
referenced: ::Selenium::WebDriver::SearchContext
::Selenium::WebDriver::SearchContext::FINDERS.merge( accessibility_id: 'accessibility id', image: '-image', custom: '-custom', # Android uiautomator: '-android uiautomator', # Unavailable in Espresso viewtag: '-android viewtag', # Available in Espresso data_matcher: '-android datamatcher', # Available in Espresso view_matcher: '-android viewmatcher', # Available in Espresso # iOS predicate: '-ios predicate string', class_chain: '-ios class chain', # Windows with windows prefix # @deprecated windows_uiautomation: '-windows uiautomation', # Tizen with Tizen prefix tizen_uiautomation: '-tizen uiautomation' )
Instance Method Summary collapse
-
#find_element(*args) ⇒ Element
rubocop:disable Layout/LineLength.
-
#find_elements(*args) ⇒ Array<Selenium::WebDriver::Element>
Find all elements matching the given arguments.
Instance Method Details
#find_element(how, what) ⇒ Element #find_element(opts) ⇒ Element
rubocop:disable Layout/LineLength
Find the first element matching the given arguments
-
Android can find with uiautomator like a UISelector.
-
iOS can find with a UIAutomation command.
-
iOS, only for XCUITest(WebDriverAgent), can find with a class chain
Find with image
Return an element if current view has a partial image. The logic depends on template matching by OpenCV. image-comparison
You can handle settings for the comparision following here
Espresso viewmatcher and datamatcher
Espresso has onView matcher and onData matcher for more reference that allows you to target adapters instead of Views. This method find methods based on reflections
This is a selector strategy that allows users to pass a selector of the form:
{ name: '<name>', args: ['arg1', 'arg2', '...'], class: '<optional class>' }
-
name: The name of a method to invoke. The method must return
a Hamcrest Matcher
-
args: The args provided to the method
-
class: The class name that the method is part of (defaults to
org.hamcrest.Matchers
).
Can be fully qualified, or simple, and simple defaults to androidx.test.espresso.matcher
package (e.g.: class=CursorMatchers
fully qualified is class=androidx.test.espresso.matcher.CursorMatchers
See example how to send viewmatcher and datamatcher in Ruby client
rubocop:enable Layout/LineLength
132 133 134 135 136 137 138 139 140 |
# File 'lib/appium_lib_core/common/base/search_context.rb', line 132 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) ⇒ Array<Selenium::WebDriver::Element>
Find all elements matching the given arguments
149 150 151 152 153 154 155 156 157 |
# File 'lib/appium_lib_core/common/base/search_context.rb', line 149 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 [] end end |