@@ -12,13 +12,14 @@ module SearchContext
12
12
# Android
13
13
uiautomator : '-android uiautomator' , # Unavailable in Espresso
14
14
viewtag : '-android viewtag' , # Available in Espresso
15
+ data_matcher : '-android datamatcher' , # Available in Espresso
15
16
# iOS
16
17
uiautomation : '-ios uiautomation' ,
17
18
predicate : '-ios predicate string' ,
18
19
class_chain : '-ios class chain' ,
19
- # Windows
20
+ # Windows with windows prefix
20
21
windows_uiautomation : '-windows uiautomation' ,
21
- # Tizen
22
+ # Tizen with Tizen prefix
22
23
tizen_uiautomation : '-tizen uiautomation'
23
24
)
24
25
# rubocop:enable Layout/AlignHash
@@ -49,47 +50,49 @@ module SearchContext
49
50
# @example Find element with each keys
50
51
#
51
52
# # with accessibility id. All platforms.
52
- # find_elements :accessibility_id, 'Animation'
53
- # find_elements :accessibility_id, 'Animation'
53
+ # @driver. find_elements :accessibility_id, 'Animation'
54
+ # @driver. find_elements :accessibility_id, 'Animation'
54
55
#
55
56
# # with base64 encoded template image. All platforms.
56
- # find_elements :image, Base64.strict_encode64(File.read(file_path))
57
+ # @driver. find_elements :image, Base64.strict_encode64(File.read(file_path))
57
58
#
58
59
# # For Android
59
60
# ## With uiautomator
60
- # find_elements :uiautomator, 'new UiSelector().clickable(true)'
61
+ # @driver. find_elements :uiautomator, 'new UiSelector().clickable(true)'
61
62
# ## With viewtag, but only for Espresso
62
63
# ## `setTag`/`getTag` in https://developer.android.com/reference/android/view/View
63
- # find_elements :viewtag, 'new UiSelector().clickable(true)'
64
+ # @driver.find_elements :viewtag, 'new UiSelector().clickable(true)'
65
+ # # With data_matcher. The argument should be JSON format.
66
+ # @driver.find_elements :data_matcher, { name: 'hasEntry', args: %w(title Animation) }.to_json
64
67
#
65
68
# # For iOS
66
69
# ## With :predicate
67
- # find_elements :predicate, "isWDVisible == 1"
68
- # find_elements :predicate, 'wdName == "Buttons"'
69
- # find_elements :predicate, 'wdValue == "SearchBar" AND isWDDivisible == 1'
70
+ # @driver. find_elements :predicate, "isWDVisible == 1"
71
+ # @driver. find_elements :predicate, 'wdName == "Buttons"'
72
+ # @driver. find_elements :predicate, 'wdValue == "SearchBar" AND isWDDivisible == 1'
70
73
#
71
74
# ## With Class Chain
72
75
# ### select the third child button of the first child window element
73
- # find_elements :class_chain, 'XCUIElementTypeWindow/XCUIElementTypeButton[3]'
76
+ # @driver. find_elements :class_chain, 'XCUIElementTypeWindow/XCUIElementTypeButton[3]'
74
77
# ### select all the children windows
75
- # find_elements :class_chain, 'XCUIElementTypeWindow'
78
+ # @driver. find_elements :class_chain, 'XCUIElementTypeWindow'
76
79
# ### select the second last child of the second child window
77
- # find_elements :class_chain, 'XCUIElementTypeWindow[2]/XCUIElementTypeAny[-2]'
80
+ # @driver. find_elements :class_chain, 'XCUIElementTypeWindow[2]/XCUIElementTypeAny[-2]'
78
81
# ### matching predicate. <code>`</code> is the mark.
79
- # find_elements :class_chain, 'XCUIElementTypeWindow[`visible = 1][`name = "bla"`]'
82
+ # @driver. find_elements :class_chain, 'XCUIElementTypeWindow[`visible = 1][`name = "bla"`]'
80
83
# ### containing predicate. `$` is the mark.
81
84
# ### Require appium-xcuitest-driver 2.54.0+. PR: https://github.com/facebook/WebDriverAgent/pull/707/files
82
- # find_elements :class_chain, 'XCUIElementTypeWindow[$name = \"bla$$$bla\"$]'
85
+ # @driver. find_elements :class_chain, 'XCUIElementTypeWindow[$name = \"bla$$$bla\"$]'
83
86
# e = find_element :class_chain, "**/XCUIElementTypeWindow[$name == 'Buttons'$]"
84
87
# e.tag_name #=> "XCUIElementTypeWindow"
85
88
# e = find_element :class_chain, "**/XCUIElementTypeStaticText[$name == 'Buttons'$]"
86
89
# e.tag_name #=> "XCUIElementTypeStaticText"
87
90
#
88
91
# # For Windows
89
- # find_elements :windows_uiautomation, '....'
92
+ # @driver. find_elements :windows_uiautomation, '....'
90
93
#
91
94
# # For Tizen
92
- # find_elements :tizen_uiautomation, '....'
95
+ # @driver. find_elements :tizen_uiautomation, '....'
93
96
#
94
97
def find_element ( *args )
95
98
how , what = extract_args ( args )
0 commit comments