Skip to content

Commit 2bb509f

Browse files
Replace mobile methods for appium 1.0
1 parent 2c8142b commit 2bb509f

File tree

6 files changed

+18
-32
lines changed

6 files changed

+18
-32
lines changed

lib/appium_lib/android/element/generic.rb

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def find val
6262
[[7, val]],
6363
# s.textContains(value);
6464
[[3, val]]
65-
mobile :find, args
65+
complex_find args
6666
end
6767

6868
# Return the first element matching text.
@@ -71,7 +71,7 @@ def find val
7171
def text text
7272
# Return the first element matching selector.
7373
# s.textContains(value)
74-
mobile :find, [[[3, text]]]
74+
complex_find [[[3, text]]]
7575
end
7676

7777
# Return all elements matching text.
@@ -89,7 +89,7 @@ def texts text
8989
def name name
9090
# work around https://github.com/appium/appium/issues/543
9191
# @driver.find_element :name, name
92-
mobile :find, [[[7, name]]]
92+
complex_find [[[7, name]]]
9393
end
9494

9595
# Return the first element exactly matching name.
@@ -99,7 +99,7 @@ def name name
9999
# @return [Element] the first matching element
100100
def name_exact name
101101
# exact description
102-
result = mobile :find, [[[5, name]]]
102+
result = complex_find [[[5, name]]]
103103

104104
return result if result.kind_of? Selenium::WebDriver::Element
105105

@@ -118,11 +118,11 @@ def name_exact name
118118
def names name=''
119119
if name.nil? || name.empty?
120120
args = 'all', [[7, ''], [100]]
121-
mobile :find, args
121+
complex_find args
122122
else
123123
args = 'all',
124124
[[7, name]]
125-
mobile :find, args
125+
complex_find args
126126
end
127127
end
128128

@@ -136,7 +136,7 @@ def scroll_to text
136136
# descriptionContains(text)
137137
[[7, text]]
138138

139-
mobile :find, args
139+
complex_find args
140140
end
141141

142142
# Scroll to an element with the exact target text or description.
@@ -149,7 +149,7 @@ def scroll_to_exact text
149149
# description(text)
150150
[[5, text]]
151151

152-
mobile :find, args
152+
complex_find args
153153
end
154154
end # module Android
155155
end # module Appium

lib/appium_lib/android/element/textfield.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def textfield text
3737
args = [[4, 'android.widget.EditText'], [7, text]],
3838
# s.className('android.widget.EditText').textContains(value);
3939
[[4, 'android.widget.EditText'], [3, text]]
40-
mobile :find, args
40+
complex_find args
4141
end
4242

4343
# Get the first textfield that matches text.

lib/appium_lib/android/helper.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ def find_eles_attr tag_name, attribute=nil
205205
206206
args = [ 'all', sel1, sel2 ]
207207
208-
mobile :find, args
208+
complex_find args
209209
=end
210210
array = ['all']
211211

@@ -214,7 +214,7 @@ def find_eles_attr tag_name, attribute=nil
214214
array.push [[4, name], [100]]
215215
end
216216

217-
mobile :find, array
217+
complex_find array
218218
end
219219

220220
# Android only.

lib/appium_lib/common/helper.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ def px_to_window_rel opts={}
298298
end
299299

300300
def lazy_load_strings
301-
@strings_xml ||= mobile(:getStrings)
301+
@strings_xml ||= app_strings
302302
end
303303

304304
# Search strings.xml's values for target.

lib/appium_lib/driver.rb

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -512,25 +512,6 @@ def execute_script script, *args
512512
@driver.execute_script script, *args
513513
end
514514

515-
# Helper method for mobile gestures
516-
#
517-
# https://github.com/appium/appium/wiki/Automating-mobile-gestures
518-
#
519-
# driver.execute_script 'mobile: swipe', endX: 100, endY: 100, duration: 0.01
520-
#
521-
# becomes
522-
#
523-
# mobile :swipe, endX: 100, endY: 100, duration: 0.01
524-
# @param method [String, Symbol] the method to execute
525-
# @param args [*args] the args to pass to the method
526-
# @return [Object]
527-
def mobile method, *args
528-
raise 'Method must not be nil' if method.nil?
529-
raise 'Method must have .to_s' unless method.respond_to? :to_s
530-
531-
@driver.execute_script "mobile: #{method.to_s}", *args
532-
end
533-
534515
# Calls @driver.find_elements
535516
#
536517
# @param args [*args] the args to use

lib/appium_lib/ios/element/generic.rb

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,9 +130,14 @@ def texts text
130130
# @return [Element] the first matching element
131131
def name name
132132
name = escape_single_quote name
133-
mobile :findElementNameContains, name: name
133+
execute_script(%Q(au.mainApp().getNameContains('#{name}')))
134134
end
135135

136+
# Return first element exactly matching name.
137+
# on Android name is content description
138+
# on iOS name is the accessibility label or the text.
139+
# @param name [String] the name to search for
140+
# @return [Element] the matching element
136141
def name_exact name
137142
name = escape_single_quote name
138143
js = all_ele_js "name == '#{name}'"

0 commit comments

Comments
 (0)