@@ -7,28 +7,28 @@ module Android
7
7
private
8
8
9
9
# @private
10
- def _button_visible_selectors opts = { }
10
+ def _button_visible_selectors ( opts = { } )
11
11
button_index = opts . fetch :button_index , false
12
12
image_button_index = opts . fetch :image_button_index , false
13
13
14
14
if button_index && image_button_index
15
- "new UiSelector().className(#{ Button } ).instance(#{ button_index } );" +
16
- "new UiSelector().className(#{ ImageButton } ).instance(#{ image_button_index } );"
15
+ "new UiSelector().className(#{ Button } ).instance(#{ button_index } );" \
16
+ "new UiSelector().className(#{ ImageButton } ).instance(#{ image_button_index } );"
17
17
else
18
- "new UiSelector().className(#{ Button } );" +
19
- "new UiSelector().className(#{ ImageButton } );"
18
+ "new UiSelector().className(#{ Button } );" \
19
+ "new UiSelector().className(#{ ImageButton } );"
20
20
end
21
21
end
22
22
23
23
# @private
24
- def _button_exact_string value
24
+ def _button_exact_string ( value )
25
25
button = string_visible_exact Button , value
26
26
image_button = string_visible_exact ImageButton , value
27
27
button + image_button
28
28
end
29
29
30
30
# @private
31
- def _button_contains_string value
31
+ def _button_contains_string ( value )
32
32
button = string_visible_contains Button , value
33
33
image_button = string_visible_contains ImageButton , value
34
34
button + image_button
@@ -40,12 +40,12 @@ def _button_contains_string value
40
40
# @param value [String, Integer] the value to exactly match.
41
41
# If int then the button at that index is returned.
42
42
# @return [Button]
43
- def button value
43
+ def button ( value )
44
44
# Don't use ele_index because that only works on one element type.
45
45
# Android needs to combine button and image button to match iOS.
46
46
if value . is_a? Numeric
47
47
index = value
48
- raise "#{ index } is not a valid index. Must be >= 1" if index <= 0
48
+ fail "#{ index } is not a valid index. Must be >= 1" if index <= 0
49
49
50
50
return find_element :uiautomator , _button_visible_selectors ( index : index )
51
51
end
@@ -57,7 +57,7 @@ def button value
57
57
# If value is omitted, all buttons are returned.
58
58
# @param value [String] the value to search for
59
59
# @return [Array<Button>]
60
- def buttons value = false
60
+ def buttons ( value = false )
61
61
return find_elements :uiautomator , _button_visible_selectors unless value
62
62
find_elements :uiautomator , _button_contains_string ( value )
63
63
end
@@ -73,28 +73,28 @@ def first_button
73
73
def last_button
74
74
# uiautomator index doesn't support last
75
75
# and it's 0 indexed
76
- button_index = tags ( Button ) . length
77
- button_index -= 1 if button_index > 0
76
+ button_index = tags ( Button ) . length
77
+ button_index -= 1 if button_index > 0
78
78
image_button_index = tags ( ImageButton ) . length
79
79
image_button_index -= 1 if image_button_index > 0
80
80
81
81
find_element :uiautomator ,
82
82
_button_visible_selectors ( button_index : button_index ,
83
- image_button_index : image_button_index )
83
+ image_button_index : image_button_index )
84
84
end
85
85
86
86
# Find the first button that exactly matches value.
87
87
# @param value [String] the value to match exactly
88
88
# @return [Button]
89
- def button_exact value
89
+ def button_exact ( value )
90
90
find_element :uiautomator , _button_exact_string ( value )
91
91
end
92
92
93
93
# Find all buttons that exactly match value.
94
94
# @param value [String] the value to match exactly
95
95
# @return [Array<Button>]
96
- def buttons_exact value
96
+ def buttons_exact ( value )
97
97
find_elements :uiautomator , _button_exact_string ( value )
98
98
end
99
99
end # module Android
100
- end # module Appium
100
+ end # module Appium
0 commit comments