appium_lib 0.24.1 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +17 -8
- data/android_tests/Gemfile +1 -0
- data/android_tests/LICENSE-2.0.txt +202 -0
- data/android_tests/Rakefile +61 -0
- data/android_tests/api.apk +0 -0
- data/android_tests/appium.txt +3 -0
- data/android_tests/flaky.txt +1 -0
- data/android_tests/lib/android/specs/android/dynamic.rb +5 -0
- data/android_tests/lib/android/specs/android/element/alert.rb +41 -0
- data/android_tests/lib/android/specs/android/element/button.rb +55 -0
- data/android_tests/lib/android/specs/android/element/generic.rb +48 -0
- data/android_tests/lib/android/specs/android/element/text.rb +39 -0
- data/android_tests/lib/android/specs/android/element/textfield.rb +60 -0
- data/android_tests/lib/android/specs/android/helper.rb +80 -0
- data/android_tests/lib/android/specs/android/patch.rb +14 -0
- data/android_tests/lib/android/specs/common/device.rb +117 -0
- data/android_tests/lib/android/specs/common/element/window.rb +9 -0
- data/android_tests/lib/android/specs/common/helper.rb +112 -0
- data/android_tests/lib/android/specs/common/patch.rb +69 -0
- data/android_tests/lib/android/specs/common/version.rb +9 -0
- data/android_tests/lib/android/specs/driver.rb +174 -0
- data/android_tests/lib/format.rb +49 -0
- data/android_tests/lib/run.rb +72 -0
- data/android_tests/readme.md +27 -0
- data/appium_lib.gemspec +8 -5
- data/docs/android_docs.md +1052 -716
- data/docs/ios_docs.md +657 -834
- data/docs_gen/make_docs.rb +1 -3
- data/ios_tests/Gemfile +1 -0
- data/ios_tests/LICENSE-2.0.txt +202 -0
- data/ios_tests/Rakefile +47 -0
- data/ios_tests/UICatalog.app.zip +0 -0
- data/ios_tests/UICatalog.app/12-6AM.png +0 -0
- data/ios_tests/UICatalog.app/12-6PM.png +0 -0
- data/ios_tests/UICatalog.app/6-12AM.png +0 -0
- data/ios_tests/UICatalog.app/6-12PM.png +0 -0
- data/ios_tests/UICatalog.app/Default-568h@2x.png +0 -0
- data/ios_tests/UICatalog.app/Default@2x.png +0 -0
- data/ios_tests/UICatalog.app/Info.plist +0 -0
- data/ios_tests/UICatalog.app/PkgInfo +1 -0
- data/ios_tests/UICatalog.app/UIButton_custom.png +0 -0
- data/ios_tests/UICatalog.app/UICatalog +0 -0
- data/ios_tests/UICatalog.app/blueButton.png +0 -0
- data/ios_tests/UICatalog.app/bookmarkImage.png +0 -0
- data/ios_tests/UICatalog.app/bookmarkImageHighlighted.png +0 -0
- data/ios_tests/UICatalog.app/divider.png +0 -0
- data/ios_tests/UICatalog.app/en.lproj/AlertsViewController.nib +0 -0
- data/ios_tests/UICatalog.app/en.lproj/ButtonsViewController.nib +0 -0
- data/ios_tests/UICatalog.app/en.lproj/ControlsViewController.nib +0 -0
- data/ios_tests/UICatalog.app/en.lproj/ImagesViewController.nib +0 -0
- data/ios_tests/UICatalog.app/en.lproj/Localizable.strings +0 -0
- data/ios_tests/UICatalog.app/en.lproj/MainWindow.nib +0 -0
- data/ios_tests/UICatalog.app/en.lproj/PickerViewController.nib +0 -0
- data/ios_tests/UICatalog.app/en.lproj/SearchBarController.nib +0 -0
- data/ios_tests/UICatalog.app/en.lproj/SegmentViewController.nib +0 -0
- data/ios_tests/UICatalog.app/en.lproj/TextFieldController.nib +0 -0
- data/ios_tests/UICatalog.app/en.lproj/TextViewController.nib +0 -0
- data/ios_tests/UICatalog.app/en.lproj/ToolbarViewController.nib +0 -0
- data/ios_tests/UICatalog.app/en.lproj/TransitionViewController.nib +0 -0
- data/ios_tests/UICatalog.app/en.lproj/WebViewController.nib +0 -0
- data/ios_tests/UICatalog.app/orangeslide.png +0 -0
- data/ios_tests/UICatalog.app/scene1.jpg +0 -0
- data/ios_tests/UICatalog.app/scene2.jpg +0 -0
- data/ios_tests/UICatalog.app/scene3.jpg +0 -0
- data/ios_tests/UICatalog.app/scene4.jpg +0 -0
- data/ios_tests/UICatalog.app/scene5.jpg +0 -0
- data/ios_tests/UICatalog.app/searchBarBackground.png +0 -0
- data/ios_tests/UICatalog.app/segment_check.png +0 -0
- data/ios_tests/UICatalog.app/segment_search.png +0 -0
- data/ios_tests/UICatalog.app/segment_tools.png +0 -0
- data/ios_tests/UICatalog.app/segmentedBackground.png +0 -0
- data/ios_tests/UICatalog.app/slider_ball.png +0 -0
- data/ios_tests/UICatalog.app/toolbarBackground.png +0 -0
- data/ios_tests/UICatalog.app/whiteButton.png +0 -0
- data/ios_tests/UICatalog.app/yellowslide.png +0 -0
- data/ios_tests/appium.txt +3 -0
- data/ios_tests/flaky.txt +1 -0
- data/ios_tests/lib/format.rb +25 -0
- data/ios_tests/lib/ios/specs/common/element/window.rb +15 -0
- data/ios_tests/lib/ios/specs/common/helper.rb +204 -0
- data/ios_tests/lib/ios/specs/common/patch.rb +50 -0
- data/ios_tests/lib/ios/specs/common/version.rb +17 -0
- data/ios_tests/lib/ios/specs/device/device.rb +82 -0
- data/ios_tests/lib/ios/specs/device/multi_touch.rb +12 -0
- data/ios_tests/lib/ios/specs/device/touch_actions.rb +15 -0
- data/ios_tests/lib/ios/specs/driver.rb +203 -0
- data/ios_tests/lib/ios/specs/ios/element/alert.rb +48 -0
- data/ios_tests/lib/ios/specs/ios/element/button.rb +58 -0
- data/ios_tests/lib/ios/specs/ios/element/generic.rb +35 -0
- data/ios_tests/lib/ios/specs/ios/element/text.rb +54 -0
- data/ios_tests/lib/ios/specs/ios/element/textfield.rb +123 -0
- data/ios_tests/lib/ios/specs/ios/helper.rb +27 -0
- data/ios_tests/lib/ios/specs/ios/patch.rb +30 -0
- data/ios_tests/lib/run.rb +106 -0
- data/ios_tests/readme.md +30 -0
- data/ios_tests/upload/sauce_storage.rb +64 -0
- data/ios_tests/upload/upload.rb +6 -0
- data/lib/appium_lib.rb +4 -14
- data/lib/appium_lib/android/dynamic.rb +30 -32
- data/lib/appium_lib/android/element/alert.rb +34 -33
- data/lib/appium_lib/android/element/button.rb +91 -0
- data/lib/appium_lib/android/element/generic.rb +51 -146
- data/lib/appium_lib/android/element/text.rb +54 -0
- data/lib/appium_lib/android/element/textfield.rb +46 -41
- data/lib/appium_lib/android/helper.rb +248 -417
- data/lib/appium_lib/android/mobile_methods.rb +17 -0
- data/lib/appium_lib/android/patch.rb +9 -8
- data/lib/appium_lib/awesome_print/ostruct.rb +33 -0
- data/lib/appium_lib/common/element/window.rb +9 -8
- data/lib/appium_lib/common/helper.rb +182 -243
- data/lib/appium_lib/common/patch.rb +65 -79
- data/lib/appium_lib/common/version.rb +2 -3
- data/lib/appium_lib/device/device.rb +339 -0
- data/lib/appium_lib/device/multi_touch.rb +94 -0
- data/lib/appium_lib/device/touch_actions.rb +142 -0
- data/lib/appium_lib/driver.rb +217 -306
- data/lib/appium_lib/ios/element/alert.rb +16 -92
- data/lib/appium_lib/ios/element/button.rb +55 -0
- data/lib/appium_lib/ios/element/generic.rb +27 -160
- data/lib/appium_lib/ios/element/text.rb +54 -0
- data/lib/appium_lib/ios/element/textfield.rb +78 -65
- data/lib/appium_lib/ios/helper.rb +300 -190
- data/lib/appium_lib/ios/mobile_methods.rb +17 -0
- data/lib/appium_lib/ios/patch.rb +55 -41
- data/lib/appium_lib/logger.rb +13 -0
- data/lib/appium_lib/rails/duplicable.rb +116 -0
- data/readme.md +6 -1
- data/release_notes.md +118 -0
- metadata +170 -12
- data/lib/appium_lib/common/element/button.rb +0 -83
- data/lib/appium_lib/common/element/text.rb +0 -61
@@ -0,0 +1,69 @@
|
|
1
|
+
=begin
|
2
|
+
Skip:
|
3
|
+
status # status patches are already tested in driver.rb
|
4
|
+
raw_execute # debug output for Pry
|
5
|
+
=end
|
6
|
+
describe 'common/patch' do
|
7
|
+
# Attributes are busted in Android.
|
8
|
+
# Blocked on https://github.com/appium/appium/issues/628
|
9
|
+
describe 'Selenium::WebDriver::Element methods' do
|
10
|
+
# Android supports exactly two string Attributes
|
11
|
+
# .name and .text
|
12
|
+
# https://github.com/appium/appium/blob/ea3450e7f78d1794bab42fa396a387e7b86fd3b3/android/bootstrap/src/io/appium/android/bootstrap/handler/GetAttribute.java#L43
|
13
|
+
# t 'value' do; end # Doesn't work on Android
|
14
|
+
|
15
|
+
t 'name' do
|
16
|
+
wait { first_s_text.name.must_equal 'API Demos' }
|
17
|
+
end
|
18
|
+
|
19
|
+
# t 'tag_name' do; end # Doesn't work on Android
|
20
|
+
|
21
|
+
t 'location_rel' do
|
22
|
+
wait do
|
23
|
+
loc = first_s_text.location_rel
|
24
|
+
loc.x.class.must_equal String
|
25
|
+
loc.y.class.must_equal String
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe 'common patch' do
|
31
|
+
# By default, the webdriver gem will return message instead of origValue
|
32
|
+
# {"message":"An unknown server-side error occurred while processing the command.","origValue":"Strategy id is not valid."}
|
33
|
+
t 'id error_message' do
|
34
|
+
value = ''
|
35
|
+
begin
|
36
|
+
set_wait 0
|
37
|
+
find_element(:id, 'ok')
|
38
|
+
rescue Exception => e;
|
39
|
+
value = e.message
|
40
|
+
ensure
|
41
|
+
set_wait 30
|
42
|
+
end
|
43
|
+
value = value.split("\n").first.strip
|
44
|
+
exp = "Could not find an element using supplied strategy. ID `ok` doesn't exist as text or content desc."
|
45
|
+
value.must_equal exp
|
46
|
+
end
|
47
|
+
|
48
|
+
t 'id success' do
|
49
|
+
wait do
|
50
|
+
el = id 'autocomplete_3_button_7' # <string name="autocomplete_3_button_7">Text</string>
|
51
|
+
el.name.must_equal 'Text'
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
t 'find many elements by resource id' do
|
56
|
+
wait do
|
57
|
+
value = find_elements(:id, 'android:id/text1').length
|
58
|
+
value.must_equal 13
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
t 'find single element by resource id' do
|
63
|
+
wait do
|
64
|
+
value = id('android:id/text1').text
|
65
|
+
value.must_equal 'Accessibility'
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
@@ -0,0 +1,174 @@
|
|
1
|
+
# rake android[driver]
|
2
|
+
describe 'driver' do
|
3
|
+
def is_sauce
|
4
|
+
ENV['UPLOAD_FILE'] && ENV['SAUCE_USERNAME']
|
5
|
+
end
|
6
|
+
|
7
|
+
t 'load_appium_txt' do
|
8
|
+
# __FILE__ is '(eval)' so use env var set by the Rakefile
|
9
|
+
parsed = Appium.load_appium_txt file: ENV['APPIUM_TXT'], verbose: true
|
10
|
+
apk_name = File.basename parsed[:caps][:app]
|
11
|
+
assert_equal apk_name, 'api.apk'
|
12
|
+
end
|
13
|
+
|
14
|
+
describe 'Appium::Driver attributes' do
|
15
|
+
# attr_reader :default_wait, :app_path, :app_name, :selendroid,
|
16
|
+
# :app_package, :app_activity, :app_wait_activity,
|
17
|
+
# :sauce_username, :sauce_access_key, :port, :os, :debug
|
18
|
+
t 'default_wait attr' do
|
19
|
+
set_wait 1
|
20
|
+
default_wait.must_equal 1
|
21
|
+
set_wait # restore default
|
22
|
+
end
|
23
|
+
|
24
|
+
t 'app_path attr' do
|
25
|
+
apk_name = File.basename driver_attributes[:caps][:app]
|
26
|
+
apk_name.must_equal 'api.apk'
|
27
|
+
end
|
28
|
+
|
29
|
+
# Only used for Sauce Labs
|
30
|
+
t 'verify all attributes' do
|
31
|
+
2.times { set_wait 1 } # must set twice to validate last_waits
|
32
|
+
actual = driver_attributes
|
33
|
+
actual[:caps][:app] = File.basename actual[:caps][:app]
|
34
|
+
expected = { caps: { platformName: 'android',
|
35
|
+
app: 'api.apk' },
|
36
|
+
custom_url: false,
|
37
|
+
export_session: false,
|
38
|
+
default_wait: 1,
|
39
|
+
last_waits: [1, 1],
|
40
|
+
sauce_username: nil,
|
41
|
+
sauce_access_key: nil,
|
42
|
+
port: 4723,
|
43
|
+
device: :android,
|
44
|
+
debug: true }
|
45
|
+
|
46
|
+
actual.must_equal expected
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
describe 'Appium::Driver' do
|
51
|
+
t '@@loaded' do
|
52
|
+
loaded = $driver.class.class_variable_get :@@loaded
|
53
|
+
loaded.must_equal true
|
54
|
+
end
|
55
|
+
|
56
|
+
t '$driver.class' do
|
57
|
+
$driver.class.must_equal Appium::Driver
|
58
|
+
end
|
59
|
+
|
60
|
+
t 'absolute_app_path' do
|
61
|
+
def absolute_app_path path;
|
62
|
+
$driver.class.absolute_app_path path;
|
63
|
+
end
|
64
|
+
|
65
|
+
def validate_path path;
|
66
|
+
absolute_app_path(path).must_equal path;
|
67
|
+
end
|
68
|
+
|
69
|
+
validate_path 'sauce-storage:some_storage_suffix'
|
70
|
+
validate_path 'http://www.saucelabs.com'
|
71
|
+
|
72
|
+
# fake real paths for osx/windows.
|
73
|
+
FakeFS.activate!
|
74
|
+
|
75
|
+
osx_existing_path = '/Users/user/myapp.app'
|
76
|
+
FileUtils.mkdir_p osx_existing_path
|
77
|
+
validate_path osx_existing_path
|
78
|
+
|
79
|
+
# TODO: FakeFS fails on Windows paths due to the drive letters.
|
80
|
+
# Look into how opscode/chef tests this.
|
81
|
+
# windows_existing_path = "C:\\Program Files\\myapp.apk"
|
82
|
+
# FileUtils.mkdir_p windows_existing_path
|
83
|
+
# validate_path windows_existing_path
|
84
|
+
|
85
|
+
FakeFS.deactivate!
|
86
|
+
|
87
|
+
# bundle id test
|
88
|
+
validate_path 'my.bundle.id'
|
89
|
+
|
90
|
+
# relative path test
|
91
|
+
relative_path = File.join __FILE__, ('..' + File::SEPARATOR) * 4, 'api.apk'
|
92
|
+
expected_path = File.expand_path relative_path
|
93
|
+
|
94
|
+
absolute_app_path(relative_path).must_equal expected_path
|
95
|
+
|
96
|
+
# invalid path test
|
97
|
+
invalid_path_errors = false
|
98
|
+
begin
|
99
|
+
absolute_app_path('../../does_not_exist.apk')
|
100
|
+
rescue Exception
|
101
|
+
invalid_path_errors = true
|
102
|
+
ensure
|
103
|
+
invalid_path_errors.must_equal true
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
describe 'methods' do
|
109
|
+
t 'status' do
|
110
|
+
appium_server_version['build'].keys.sort.must_equal %w(revision version)
|
111
|
+
end
|
112
|
+
|
113
|
+
t 'server_version' do
|
114
|
+
server_version = appium_server_version['build']['version']
|
115
|
+
if is_sauce
|
116
|
+
server_version.must_match 'Sauce OnDemand'
|
117
|
+
else
|
118
|
+
server_version.must_match /(\d+)\.(\d+).(\d+)/
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
=begin
|
123
|
+
Skip:
|
124
|
+
ios_capabilities # save for iOS tests
|
125
|
+
absolute_app_path # tested already by starting the driver for this test
|
126
|
+
server_url # sauce labs only
|
127
|
+
=end
|
128
|
+
t 'restart' do
|
129
|
+
set_wait 1 # ensure wait is 1 before we restart.
|
130
|
+
restart
|
131
|
+
current_activity.must_equal '.ApiDemos'
|
132
|
+
end
|
133
|
+
|
134
|
+
t 'driver' do
|
135
|
+
driver.browser.must_equal :Android
|
136
|
+
end
|
137
|
+
|
138
|
+
=begin
|
139
|
+
Skip:
|
140
|
+
screenshot # this is slow and already tested by Appium
|
141
|
+
driver_quit # tested by restart
|
142
|
+
start_driver # tested by restart
|
143
|
+
no_wait # posts value to server, it's not stored locally
|
144
|
+
set_wait # posts value to server, it's not stored locally
|
145
|
+
execute_script # 'mobile: ' is deprecated and plain executeScript unsupported
|
146
|
+
=end
|
147
|
+
t 'default_wait' do
|
148
|
+
set_wait 1
|
149
|
+
default_wait.must_equal 1
|
150
|
+
end
|
151
|
+
|
152
|
+
# returns true unless an error is raised
|
153
|
+
t 'exists' do
|
154
|
+
exists(0, 0) { true }.must_equal true
|
155
|
+
exists(0, 0) { raise 'error' }.must_equal false
|
156
|
+
end
|
157
|
+
|
158
|
+
# any elements
|
159
|
+
t 'find_elements' do
|
160
|
+
wait do
|
161
|
+
find_elements(:class_name, 'android.widget.TextView').length.must_equal 14
|
162
|
+
end
|
163
|
+
end
|
164
|
+
|
165
|
+
# any element
|
166
|
+
t 'find_element' do
|
167
|
+
wait do
|
168
|
+
find_element(:class_name, 'android.widget.TextView').class.must_equal Selenium::WebDriver::Element
|
169
|
+
end
|
170
|
+
end
|
171
|
+
|
172
|
+
# Skip: x # x is only used in Pry
|
173
|
+
end
|
174
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
# helper code useful for writing and verifying tests using Pry
|
2
|
+
list = <<TXT
|
3
|
+
find
|
4
|
+
text
|
5
|
+
texts
|
6
|
+
name
|
7
|
+
names
|
8
|
+
scroll_to
|
9
|
+
TXT
|
10
|
+
|
11
|
+
list.split("\n").each do |method|
|
12
|
+
puts "t '#{method}' do"
|
13
|
+
puts
|
14
|
+
puts 'end'
|
15
|
+
puts
|
16
|
+
end
|
17
|
+
|
18
|
+
# --
|
19
|
+
|
20
|
+
# Format AndroidElementClassMap from
|
21
|
+
# https://github.com/appium/appium/blob/master/android/bootstrap/src/io/appium/android/bootstrap/AndroidElementClassMap.java
|
22
|
+
# for ruby_lib android/helper.rb tag_name_to_android
|
23
|
+
list = <<TXT
|
24
|
+
map.put("abslist", "AbsListView");
|
25
|
+
map.put("button", "Button");
|
26
|
+
TXT
|
27
|
+
|
28
|
+
list.split("\n").each do |method|
|
29
|
+
pair = method.match /"([^"]+)"[^"]+"([^"]+)"/
|
30
|
+
tag = pair[1]
|
31
|
+
klass = pair[2]
|
32
|
+
|
33
|
+
indent = 6
|
34
|
+
puts ' ' * indent + "when '" + tag + "'"
|
35
|
+
line2 = ' ' * (indent + 2) + "prefix '" + klass + "'"
|
36
|
+
# button must translate to both button and image button
|
37
|
+
# for ruby_lib to find all buttons
|
38
|
+
line2 += ", 'ImageButton'" if klass == 'Button'
|
39
|
+
puts line2
|
40
|
+
end
|
41
|
+
|
42
|
+
=begin
|
43
|
+
# for Pry
|
44
|
+
class Object
|
45
|
+
def must_equal b
|
46
|
+
raise 'not equal' unless self == b
|
47
|
+
end
|
48
|
+
end
|
49
|
+
=end
|
@@ -0,0 +1,72 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'spec'
|
3
|
+
require 'fakefs/safe'
|
4
|
+
require_relative '../../lib/appium_lib'
|
5
|
+
|
6
|
+
=begin
|
7
|
+
Run all Android tests:
|
8
|
+
ruby run.rb android
|
9
|
+
|
10
|
+
Run only the view album test:
|
11
|
+
ruby run.rb android view_album
|
12
|
+
=end
|
13
|
+
|
14
|
+
# Sanity check
|
15
|
+
a = OpenStruct.new x: 'ok'
|
16
|
+
raise 'x issue' unless a.x == 'ok'
|
17
|
+
|
18
|
+
dir = File.expand_path '..', __FILE__
|
19
|
+
device = ARGV[0].downcase.strip
|
20
|
+
devices = %w[ android selendroid ios ]
|
21
|
+
raise 'Expected android, selendroid or ios as first argument' unless devices.include? device
|
22
|
+
|
23
|
+
one_test = ARGV[1]
|
24
|
+
test_dir = "/#{device}/"
|
25
|
+
|
26
|
+
caps = Appium.load_appium_txt file: ENV['APPIUM_TXT'], verbose: true
|
27
|
+
caps = caps.merge({ appium_lib: { debug: true, wait: 1 } })
|
28
|
+
caps[:app] = ENV['SAUCE_PATH'] if ENV['SAUCE_USERNAME'] && ENV['SAUCE_ACCESS_KEY']
|
29
|
+
|
30
|
+
trace_files = []
|
31
|
+
|
32
|
+
if one_test
|
33
|
+
unless File.exists? one_test
|
34
|
+
# ensure ext is .rb
|
35
|
+
one_test = File.join(File.dirname(one_test),
|
36
|
+
File.basename(one_test, '.*') + '.rb')
|
37
|
+
one_test = File.join(dir, test_dir + 'specs/', one_test)
|
38
|
+
else
|
39
|
+
one_test = File.expand_path one_test
|
40
|
+
end
|
41
|
+
raise "\nTest #{one_test} does not exist.\n" unless File.exists?(one_test)
|
42
|
+
Appium::Driver.new(caps).start_driver
|
43
|
+
# require support (common.rb)
|
44
|
+
Dir.glob(File.join dir, test_dir + '/*.rb') do |test|
|
45
|
+
require test
|
46
|
+
trace_files << test
|
47
|
+
end
|
48
|
+
puts "Loading one test: #{one_test}"
|
49
|
+
require one_test
|
50
|
+
trace_files << one_test
|
51
|
+
else
|
52
|
+
# require all
|
53
|
+
Dir.glob(File.join dir, test_dir + '**/*.rb') do |test|
|
54
|
+
# load all tests
|
55
|
+
trace_files << test
|
56
|
+
puts " #{File.basename(test, '.*')}"
|
57
|
+
require test
|
58
|
+
end
|
59
|
+
Appium::Driver.new(caps).start_driver
|
60
|
+
end
|
61
|
+
|
62
|
+
trace_files.map! do |f|
|
63
|
+
f = File.expand_path f
|
64
|
+
# ensure all traced files end in .rb
|
65
|
+
f = File.join(File.dirname(f), File.basename(f, '.*') + '.rb')
|
66
|
+
f
|
67
|
+
end
|
68
|
+
|
69
|
+
# Exit after tests.
|
70
|
+
Minitest.after_run { $driver.x if $driver }
|
71
|
+
# Run Minitest. Provide test file array for tracing.
|
72
|
+
Minitest.run_specs({ :trace => trace_files })
|
@@ -0,0 +1,27 @@
|
|
1
|
+
ruby_lib_android
|
2
|
+
=====================
|
3
|
+
|
4
|
+
ruby_lib's Android tests. Requires `Ruby 1.9.3` or better.
|
5
|
+
|
6
|
+
- `rake install` Install gems required to run the tests.
|
7
|
+
- `rake android` Run all tests.
|
8
|
+
- `rake android['android/element/generic']` Run a single test.
|
9
|
+
- `arc` Opens the Appium Ruby Console (arc). Enables interactive testing.
|
10
|
+
- `gem install appium_console` if it's not installed already.
|
11
|
+
|
12
|
+
api.apk is from [appium/android-apidemos](https://github.com/appium/android-apidemos)
|
13
|
+
|
14
|
+
#### Documentation
|
15
|
+
|
16
|
+
- [Installing Appium on OS X](https://github.com/appium/ruby_console/blob/master/osx.md)
|
17
|
+
- [Overview](https://github.com/appium/ruby_lib/blob/master/docs/docs.md)
|
18
|
+
- [Android methods](https://github.com/appium/ruby_lib/blob/master/docs/android_docs.md)
|
19
|
+
- [Minitest Expectations](http://ruby-doc.org/stdlib-1.9.3/libdoc/minitest/spec/rdoc/MiniTest/Expectations.html)
|
20
|
+
|
21
|
+
--
|
22
|
+
|
23
|
+
```java
|
24
|
+
Finished in 2 mins 8 secs
|
25
|
+
|
26
|
+
94 runs, 120 assertions, 0 failures, 0 errors, 0 skips
|
27
|
+
```
|
data/appium_lib.gemspec
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
1
|
def self.add_to_path path
|
4
2
|
path = File.expand_path "../#{path}/", __FILE__
|
5
3
|
|
@@ -24,14 +22,19 @@ Gem::Specification.new do |s|
|
|
24
22
|
s.homepage = 'https://github.com/appium/ruby_lib' # published as appium_lib
|
25
23
|
s.require_paths = [ 'lib' ]
|
26
24
|
|
27
|
-
s.add_runtime_dependency 'selenium-webdriver', '~> 2.
|
25
|
+
s.add_runtime_dependency 'selenium-webdriver', '~> 2.41', '>= 2.41.0'
|
28
26
|
s.add_runtime_dependency 'awesome_print', '~> 1.2', '>= 1.2.0'
|
29
27
|
s.add_runtime_dependency 'json', '~> 1.8', '>= 1.8.1'
|
30
28
|
s.add_runtime_dependency 'toml', '~> 0.0', '>= 0.0.4'
|
31
29
|
s.add_runtime_dependency 'posix-spawn', '~> 0.3', '>= 0.3.8'
|
30
|
+
s.add_runtime_dependency 'nokogiri', '~> 1.6.1'
|
31
|
+
|
32
|
+
s.add_development_dependency 'hashdiff', '~> 0.2.0'
|
33
|
+
s.add_development_dependency 'spec', '~> 5.3.4'
|
34
|
+
s.add_development_dependency 'fakefs', '~> 0.5.0'
|
32
35
|
|
33
|
-
s.add_development_dependency 'rake', '~> 10.
|
36
|
+
s.add_development_dependency 'rake', '~> 10.2', '>= 10.2.2'
|
34
37
|
s.add_development_dependency 'yard', '~> 0.8', '>= 0.8.7.3'
|
35
38
|
|
36
39
|
s.files = `git ls-files`.split "\n"
|
37
|
-
end
|
40
|
+
end
|
data/docs/android_docs.md
CHANGED
@@ -1,941 +1,936 @@
|
|
1
|
-
##### [
|
1
|
+
##### [load_appium_txt](https://github.com/appium/ruby_lib/blob/5a3ecbb4147693ce3c2c6b693e64074022d03511/lib/appium_lib/driver.rb#L71)
|
2
2
|
|
3
|
-
> def
|
3
|
+
> def self.load_appium_txt opts={}
|
4
4
|
|
5
|
-
|
6
|
-
|
5
|
+
Load appium.txt (toml format)
|
6
|
+
the basedir of this file + appium.txt is what's used
|
7
|
+
|
8
|
+
```
|
9
|
+
[caps]
|
10
|
+
app = "path/to/app"
|
11
|
+
|
12
|
+
[appium_lib]
|
13
|
+
port = 8080
|
14
|
+
```
|
15
|
+
|
16
|
+
:app is expanded
|
17
|
+
:require is expanded
|
18
|
+
all keys are converted to symbols
|
7
19
|
|
8
20
|
__Parameters:__
|
9
21
|
|
10
|
-
[
|
22
|
+
[Hash] opts - file: '/path/to/appium.txt', verbose: true
|
11
23
|
|
12
24
|
__Returns:__
|
13
25
|
|
14
|
-
[
|
26
|
+
[hash] the symbolized hash with updated :app and :require keys
|
15
27
|
|
16
28
|
--
|
17
29
|
|
18
|
-
##### [
|
30
|
+
##### [symbolize_keys](https://github.com/appium/ruby_lib/blob/5a3ecbb4147693ce3c2c6b693e64074022d03511/lib/appium_lib/driver.rb#L141)
|
19
31
|
|
20
|
-
> def
|
32
|
+
> def self.symbolize_keys hash
|
21
33
|
|
34
|
+
convert all keys (including nested) to symbols
|
22
35
|
|
36
|
+
based on deep_symbolize_keys & deep_transform_keys from rails
|
37
|
+
https://github.com/rails/docrails/blob/a3b1105ada3da64acfa3843b164b14b734456a50/activesupport/lib/active_support/core_ext/hash/keys.rb#L84
|
23
38
|
|
24
39
|
--
|
25
40
|
|
26
|
-
##### [
|
41
|
+
##### [promote_singleton_appium_methods](https://github.com/appium/ruby_lib/blob/5a3ecbb4147693ce3c2c6b693e64074022d03511/lib/appium_lib/driver.rb#L151)
|
27
42
|
|
28
|
-
> def
|
29
|
-
|
30
|
-
Get an array of text elements.
|
43
|
+
> def self.promote_singleton_appium_methods main_module
|
31
44
|
|
32
|
-
__Returns:__
|
33
45
|
|
34
|
-
[Array<Text>]
|
35
46
|
|
36
47
|
--
|
37
48
|
|
38
|
-
##### [
|
49
|
+
##### [promote_appium_methods](https://github.com/appium/ruby_lib/blob/5a3ecbb4147693ce3c2c6b693e64074022d03511/lib/appium_lib/driver.rb#L180)
|
39
50
|
|
40
|
-
> def
|
51
|
+
> def self.promote_appium_methods class_array
|
41
52
|
|
42
|
-
|
53
|
+
Promote appium methods to class instance methods
|
43
54
|
|
44
|
-
|
55
|
+
To promote methods to all classes:
|
45
56
|
|
46
|
-
|
57
|
+
```ruby
|
58
|
+
Appium.promote_appium_methods Object
|
59
|
+
```
|
47
60
|
|
48
|
-
|
61
|
+
__Parameters:__
|
49
62
|
|
50
|
-
|
63
|
+
[Array<Class>] class_array - An array of classes
|
51
64
|
|
52
|
-
|
65
|
+
--
|
53
66
|
|
54
|
-
|
67
|
+
##### [global_webdriver_http_sleep](https://github.com/appium/ruby_lib/blob/5a3ecbb4147693ce3c2c6b693e64074022d03511/lib/appium_lib/driver.rb#L213)
|
55
68
|
|
56
|
-
|
69
|
+
> def global_webdriver_http_sleep
|
57
70
|
|
58
|
-
|
71
|
+
The amount to sleep in seconds before every webdriver http call.
|
59
72
|
|
60
73
|
--
|
61
74
|
|
62
|
-
##### [
|
75
|
+
##### [global_webdriver_http_sleep=](https://github.com/appium/ruby_lib/blob/5a3ecbb4147693ce3c2c6b693e64074022d03511/lib/appium_lib/driver.rb#L213)
|
63
76
|
|
64
|
-
> def
|
77
|
+
> def global_webdriver_http_sleep=(value)
|
65
78
|
|
66
|
-
|
79
|
+
The amount to sleep in seconds before every webdriver http call.
|
67
80
|
|
68
|
-
|
81
|
+
--
|
69
82
|
|
70
|
-
|
83
|
+
##### [initialize](https://github.com/appium/ruby_lib/blob/5a3ecbb4147693ce3c2c6b693e64074022d03511/lib/appium_lib/driver.rb#L234)
|
71
84
|
|
72
|
-
|
85
|
+
> def initialize opts={}
|
73
86
|
|
74
|
-
|
87
|
+
Creates a new driver
|
75
88
|
|
76
|
-
|
89
|
+
```ruby
|
90
|
+
require 'rubygems'
|
91
|
+
require 'appium_lib'
|
77
92
|
|
78
|
-
|
93
|
+
# platformName takes a string or a symbol.
|
79
94
|
|
80
|
-
|
95
|
+
# Start iOS driver
|
96
|
+
opts = { caps: { platformName: :ios, app: '/path/to/MyiOS.app' } }
|
97
|
+
Appium::Driver.new(opts).start_driver
|
81
98
|
|
82
|
-
|
99
|
+
# Start Android driver
|
100
|
+
opts = { caps: { platformName: :android, app: '/path/to/my.apk' } }
|
101
|
+
Appium::Driver.new(apk).start_driver
|
102
|
+
```
|
83
103
|
|
84
104
|
__Parameters:__
|
85
105
|
|
86
|
-
[
|
106
|
+
[Object] opts - A hash containing various options.
|
87
107
|
|
88
108
|
__Returns:__
|
89
109
|
|
90
|
-
[
|
110
|
+
[Driver]
|
91
111
|
|
92
112
|
--
|
93
113
|
|
94
|
-
##### [
|
114
|
+
##### [driver_attributes](https://github.com/appium/ruby_lib/blob/5a3ecbb4147693ce3c2c6b693e64074022d03511/lib/appium_lib/driver.rb#L308)
|
95
115
|
|
96
|
-
> def
|
116
|
+
> def driver_attributes
|
97
117
|
|
98
|
-
|
118
|
+
Returns a hash of the driver attributes
|
119
|
+
|
120
|
+
--
|
121
|
+
|
122
|
+
##### [device_is_android?](https://github.com/appium/ruby_lib/blob/5a3ecbb4147693ce3c2c6b693e64074022d03511/lib/appium_lib/driver.rb#L328)
|
123
|
+
|
124
|
+
> def device_is_android?
|
99
125
|
|
100
|
-
__Parameters:__
|
101
126
|
|
102
|
-
[String] text - the text that the tag must match
|
103
127
|
|
104
128
|
__Returns:__
|
105
129
|
|
106
|
-
[
|
130
|
+
[Boolean]
|
107
131
|
|
108
132
|
--
|
109
133
|
|
110
|
-
##### [
|
134
|
+
##### [appium_server_version](https://github.com/appium/ruby_lib/blob/5a3ecbb4147693ce3c2c6b693e64074022d03511/lib/appium_lib/driver.rb#L344)
|
111
135
|
|
112
|
-
> def
|
136
|
+
> def appium_server_version
|
113
137
|
|
114
|
-
|
138
|
+
Returns the server's version info
|
115
139
|
|
116
|
-
|
140
|
+
```ruby
|
141
|
+
{
|
142
|
+
"build" => {
|
143
|
+
"version" => "0.18.1",
|
144
|
+
"revision" => "d242ebcfd92046a974347ccc3a28f0e898595198"
|
145
|
+
}
|
146
|
+
}
|
147
|
+
```
|
117
148
|
|
118
|
-
|
149
|
+
__Returns:__
|
119
150
|
|
120
|
-
|
151
|
+
[Hash]
|
121
152
|
|
122
|
-
|
153
|
+
--
|
123
154
|
|
124
|
-
|
155
|
+
##### [absolute_app_path](https://github.com/appium/ruby_lib/blob/5a3ecbb4147693ce3c2c6b693e64074022d03511/lib/appium_lib/driver.rb#L350)
|
125
156
|
|
126
|
-
|
157
|
+
> def self.absolute_app_path app_path
|
127
158
|
|
128
|
-
|
159
|
+
Converts app_path to an absolute path.
|
129
160
|
|
130
161
|
__Returns:__
|
131
162
|
|
132
|
-
[
|
163
|
+
[String] APP_PATH as an absolute path
|
133
164
|
|
134
165
|
--
|
135
166
|
|
136
|
-
##### [
|
137
|
-
|
138
|
-
> def buttons text=nil
|
167
|
+
##### [server_url](https://github.com/appium/ruby_lib/blob/5a3ecbb4147693ce3c2c6b693e64074022d03511/lib/appium_lib/driver.rb#L374)
|
139
168
|
|
140
|
-
|
141
|
-
|
142
|
-
__Parameters:__
|
169
|
+
> def server_url
|
143
170
|
|
144
|
-
|
171
|
+
Get the server url
|
145
172
|
|
146
173
|
__Returns:__
|
147
174
|
|
148
|
-
[
|
175
|
+
[String] the server url
|
149
176
|
|
150
177
|
--
|
151
178
|
|
152
|
-
##### [
|
179
|
+
##### [restart](https://github.com/appium/ruby_lib/blob/5a3ecbb4147693ce3c2c6b693e64074022d03511/lib/appium_lib/driver.rb#L385)
|
153
180
|
|
154
|
-
> def
|
181
|
+
> def restart
|
155
182
|
|
156
|
-
|
183
|
+
Restarts the driver
|
157
184
|
|
158
185
|
__Returns:__
|
159
186
|
|
160
|
-
[
|
187
|
+
[Driver] the driver
|
161
188
|
|
162
189
|
--
|
163
190
|
|
164
|
-
##### [
|
191
|
+
##### [driver](https://github.com/appium/ruby_lib/blob/5a3ecbb4147693ce3c2c6b693e64074022d03511/lib/appium_lib/driver.rb#L392)
|
165
192
|
|
166
|
-
> def
|
193
|
+
> def driver
|
167
194
|
|
168
|
-
|
195
|
+
Returns the driver
|
169
196
|
|
170
197
|
__Returns:__
|
171
198
|
|
172
|
-
[
|
199
|
+
[Driver] the driver
|
173
200
|
|
174
201
|
--
|
175
202
|
|
176
|
-
##### [
|
203
|
+
##### [screenshot](https://github.com/appium/ruby_lib/blob/5a3ecbb4147693ce3c2c6b693e64074022d03511/lib/appium_lib/driver.rb#L402)
|
177
204
|
|
178
|
-
> def
|
205
|
+
> def screenshot png_save_path
|
206
|
+
|
207
|
+
Takes a png screenshot and saves to the target path.
|
179
208
|
|
180
|
-
|
209
|
+
Example: screenshot '/tmp/hi.png'
|
181
210
|
|
182
211
|
__Parameters:__
|
183
212
|
|
184
|
-
[String]
|
213
|
+
[String] png_save_path - the full path to save the png
|
185
214
|
|
186
215
|
__Returns:__
|
187
216
|
|
188
|
-
[
|
217
|
+
[nil]
|
189
218
|
|
190
219
|
--
|
191
220
|
|
192
|
-
##### [
|
193
|
-
|
194
|
-
> def buttons_exact text
|
221
|
+
##### [driver_quit](https://github.com/appium/ruby_lib/blob/5a3ecbb4147693ce3c2c6b693e64074022d03511/lib/appium_lib/driver.rb#L409)
|
195
222
|
|
196
|
-
|
197
|
-
|
198
|
-
__Parameters:__
|
223
|
+
> def driver_quit
|
199
224
|
|
200
|
-
|
225
|
+
Quits the driver
|
201
226
|
|
202
227
|
__Returns:__
|
203
228
|
|
204
|
-
[
|
229
|
+
[void]
|
205
230
|
|
206
231
|
--
|
207
232
|
|
208
|
-
##### [
|
233
|
+
##### [start_driver](https://github.com/appium/ruby_lib/blob/5a3ecbb4147693ce3c2c6b693e64074022d03511/lib/appium_lib/driver.rb#L417)
|
209
234
|
|
210
|
-
> def
|
235
|
+
> def start_driver
|
211
236
|
|
212
|
-
|
237
|
+
Creates a new global driver and quits the old one if it exists.
|
213
238
|
|
214
239
|
__Returns:__
|
215
240
|
|
216
|
-
[
|
241
|
+
[Selenium::WebDriver] the new global driver
|
217
242
|
|
218
243
|
--
|
219
244
|
|
220
|
-
##### [
|
245
|
+
##### [no_wait](https://github.com/appium/ruby_lib/blob/5a3ecbb4147693ce3c2c6b693e64074022d03511/lib/appium_lib/driver.rb#L443)
|
246
|
+
|
247
|
+
> def no_wait
|
248
|
+
|
249
|
+
Set implicit wait and default_wait to zero.
|
221
250
|
|
222
|
-
|
251
|
+
--
|
223
252
|
|
224
|
-
|
253
|
+
##### [set_wait](https://github.com/appium/ruby_lib/blob/5a3ecbb4147693ce3c2c6b693e64074022d03511/lib/appium_lib/driver.rb#L462)
|
225
254
|
|
226
|
-
|
227
|
-
occurrence. number=2 means the 2nd occurrence.
|
255
|
+
> def set_wait timeout=nil
|
228
256
|
|
229
|
-
|
257
|
+
Set implicit wait and default_wait to timeout, defaults to 30.
|
258
|
+
if set_wait is called without a param then the second to last
|
259
|
+
wait will be used.
|
230
260
|
|
231
|
-
|
261
|
+
```ruby`
|
262
|
+
set_wait 2
|
263
|
+
set_wait 3
|
264
|
+
set_wait # 2
|
232
265
|
|
233
|
-
|
234
|
-
so if there's no button found at number then
|
235
|
-
return the first button.
|
266
|
+
````
|
236
267
|
|
237
268
|
__Parameters:__
|
238
269
|
|
239
|
-
[
|
240
|
-
|
241
|
-
[Integer] number - the button occurance to return. 1 = first button
|
270
|
+
[Integer] timeout - the timeout in seconds
|
242
271
|
|
243
272
|
__Returns:__
|
244
273
|
|
245
|
-
[
|
274
|
+
[void]
|
246
275
|
|
247
276
|
--
|
248
277
|
|
249
|
-
##### [
|
278
|
+
##### [default_wait](https://github.com/appium/ruby_lib/blob/5a3ecbb4147693ce3c2c6b693e64074022d03511/lib/appium_lib/driver.rb#L480)
|
250
279
|
|
251
|
-
> def
|
252
|
-
|
253
|
-
Returns an array of android classes that match the tag name
|
254
|
-
|
255
|
-
__Parameters:__
|
280
|
+
> def default_wait
|
256
281
|
|
257
|
-
|
282
|
+
Returns the default client side wait.
|
283
|
+
This value is independent of what the server is using
|
258
284
|
|
259
285
|
__Returns:__
|
260
286
|
|
261
|
-
[
|
287
|
+
[Integer]
|
262
288
|
|
263
289
|
--
|
264
290
|
|
265
|
-
##### [
|
291
|
+
##### [exists](https://github.com/appium/ruby_lib/blob/5a3ecbb4147693ce3c2c6b693e64074022d03511/lib/appium_lib/driver.rb#L496)
|
266
292
|
|
267
|
-
> def
|
293
|
+
> def exists pre_check=0, post_check=@default_wait, &search_block
|
268
294
|
|
269
|
-
|
270
|
-
On android, assume the attr is name (which falls back to text).
|
295
|
+
Returns existence of element.
|
271
296
|
|
272
|
-
|
273
|
-
|
274
|
-
|
297
|
+
Example:
|
298
|
+
|
299
|
+
exists { button('sign in') } ? puts('true') : puts('false')
|
275
300
|
|
276
301
|
__Parameters:__
|
277
302
|
|
278
|
-
[
|
303
|
+
[Integer] pre_check - the amount in seconds to set the
|
304
|
+
wait to before checking existance
|
305
|
+
|
306
|
+
[Integer] post_check - the amount in seconds to set the
|
307
|
+
wait to after checking existance
|
308
|
+
|
309
|
+
[Block] search_block - the block to call
|
279
310
|
|
280
311
|
__Returns:__
|
281
312
|
|
282
|
-
[
|
313
|
+
[Boolean]
|
283
314
|
|
284
315
|
--
|
285
316
|
|
286
|
-
##### [
|
317
|
+
##### [execute_script](https://github.com/appium/ruby_lib/blob/5a3ecbb4147693ce3c2c6b693e64074022d03511/lib/appium_lib/driver.rb#L520)
|
287
318
|
|
288
|
-
> def
|
319
|
+
> def execute_script script, *args
|
289
320
|
|
290
|
-
|
291
|
-
|
321
|
+
The same as @driver.execute_script
|
322
|
+
|
323
|
+
__Parameters:__
|
324
|
+
|
325
|
+
[String] script - the script to execute
|
326
|
+
|
327
|
+
[*args] args - the args to pass to the script
|
292
328
|
|
293
329
|
__Returns:__
|
294
330
|
|
295
|
-
[
|
331
|
+
[Object]
|
296
332
|
|
297
333
|
--
|
298
334
|
|
299
|
-
##### [
|
300
|
-
|
301
|
-
> def get_page_class
|
335
|
+
##### [find_elements](https://github.com/appium/ruby_lib/blob/5a3ecbb4147693ce3c2c6b693e64074022d03511/lib/appium_lib/driver.rb#L528)
|
302
336
|
|
337
|
+
> def find_elements *args
|
303
338
|
|
339
|
+
Calls @driver.find_elements
|
304
340
|
|
305
|
-
|
341
|
+
__Parameters:__
|
306
342
|
|
307
|
-
|
343
|
+
[*args] args - the args to use
|
308
344
|
|
309
|
-
|
345
|
+
__Returns:__
|
310
346
|
|
311
|
-
|
312
|
-
Useful for appium_console.
|
347
|
+
[Array<Element>] Array is empty when no elements are found.
|
313
348
|
|
314
349
|
--
|
315
350
|
|
316
|
-
##### [
|
351
|
+
##### [find_element](https://github.com/appium/ruby_lib/blob/5a3ecbb4147693ce3c2c6b693e64074022d03511/lib/appium_lib/driver.rb#L536)
|
352
|
+
|
353
|
+
> def find_element *args
|
317
354
|
|
318
|
-
|
355
|
+
Calls @driver.find_elements
|
319
356
|
|
320
|
-
|
321
|
-
|
322
|
-
|
357
|
+
__Parameters:__
|
358
|
+
|
359
|
+
[*args] args - the args to use
|
323
360
|
|
324
361
|
__Returns:__
|
325
362
|
|
326
|
-
[
|
363
|
+
[Element]
|
327
364
|
|
328
365
|
--
|
329
366
|
|
330
|
-
##### [
|
367
|
+
##### [x](https://github.com/appium/ruby_lib/blob/5a3ecbb4147693ce3c2c6b693e64074022d03511/lib/appium_lib/driver.rb#L543)
|
331
368
|
|
332
|
-
> def
|
369
|
+
> def x
|
333
370
|
|
334
|
-
|
335
|
-
|
371
|
+
Quit the driver and Pry.
|
372
|
+
quit and exit are reserved by Pry.
|
336
373
|
|
337
374
|
__Returns:__
|
338
375
|
|
339
|
-
[
|
376
|
+
[void]
|
340
377
|
|
341
378
|
--
|
342
379
|
|
343
|
-
##### [
|
380
|
+
##### [NoArgMethods](https://github.com/appium/ruby_lib/blob/5a3ecbb4147693ce3c2c6b693e64074022d03511/lib/appium_lib/device/device.rb#L7)
|
344
381
|
|
345
|
-
>
|
382
|
+
> NoArgMethods = {
|
346
383
|
|
347
|
-
Intended for use with console.
|
348
|
-
Inspects and prints the current page.
|
349
384
|
|
350
|
-
--
|
351
385
|
|
352
|
-
|
386
|
+
--
|
353
387
|
|
354
|
-
|
388
|
+
##### [app_strings](https://github.com/appium/ruby_lib/blob/5a3ecbb4147693ce3c2c6b693e64074022d03511/lib/appium_lib/device/device.rb#L23)
|
355
389
|
|
356
|
-
|
390
|
+
> def app_strings
|
357
391
|
|
358
|
-
|
359
|
-
|
392
|
+
Return the hash of all localization strings.
|
393
|
+
```ruby
|
394
|
+
app_strings #=> "TransitionsTitle"=>"Transitions", "WebTitle"=>"Web"
|
360
395
|
```
|
361
396
|
|
362
|
-
We want steps to be exactly 1. If it's zero then a tap is used instead of a swipe.
|
363
|
-
|
364
397
|
--
|
365
398
|
|
366
|
-
##### [
|
399
|
+
##### [background_app](https://github.com/appium/ruby_lib/blob/5a3ecbb4147693ce3c2c6b693e64074022d03511/lib/appium_lib/device/device.rb#L29)
|
367
400
|
|
368
|
-
> def
|
401
|
+
> def background_app
|
369
402
|
|
370
|
-
|
371
|
-
|
403
|
+
Backgrounds the app for a set number of seconds.
|
404
|
+
This is a blocking application
|
372
405
|
|
373
406
|
--
|
374
407
|
|
375
|
-
##### [
|
408
|
+
##### [current_activity](https://github.com/appium/ruby_lib/blob/5a3ecbb4147693ce3c2c6b693e64074022d03511/lib/appium_lib/device/device.rb#L34)
|
376
409
|
|
377
|
-
> def
|
410
|
+
> def current_activity
|
378
411
|
|
379
|
-
Find by id. Useful for selendroid
|
380
412
|
|
381
|
-
__Parameters:__
|
382
413
|
|
383
|
-
|
414
|
+
--
|
384
415
|
|
385
|
-
|
416
|
+
##### [launch](https://github.com/appium/ruby_lib/blob/5a3ecbb4147693ce3c2c6b693e64074022d03511/lib/appium_lib/device/device.rb#L36)
|
386
417
|
|
387
|
-
|
418
|
+
> def launch
|
419
|
+
|
420
|
+
Start the simulator and applicaton configured with desired capabilities
|
388
421
|
|
389
422
|
--
|
390
423
|
|
391
|
-
##### [
|
424
|
+
##### [reset](https://github.com/appium/ruby_lib/blob/5a3ecbb4147693ce3c2c6b693e64074022d03511/lib/appium_lib/device/device.rb#L39)
|
392
425
|
|
393
|
-
> def
|
426
|
+
> def reset
|
394
427
|
|
395
|
-
|
428
|
+
Reset the device, relaunching the application.
|
396
429
|
|
397
|
-
|
430
|
+
--
|
398
431
|
|
399
|
-
|
432
|
+
##### [shake](https://github.com/appium/ruby_lib/blob/5a3ecbb4147693ce3c2c6b693e64074022d03511/lib/appium_lib/device/device.rb#L42)
|
400
433
|
|
401
|
-
|
434
|
+
> def shake
|
402
435
|
|
403
|
-
|
436
|
+
Cause the device to shake
|
404
437
|
|
405
438
|
--
|
406
439
|
|
407
|
-
##### [
|
440
|
+
##### [toggle_flight_mode](https://github.com/appium/ruby_lib/blob/5a3ecbb4147693ce3c2c6b693e64074022d03511/lib/appium_lib/device/device.rb#L45)
|
408
441
|
|
409
|
-
> def
|
442
|
+
> def toggle_flight_mode
|
410
443
|
|
411
|
-
|
412
|
-
The last button is considered "accept."
|
444
|
+
toggle flight mode on or off
|
413
445
|
|
414
|
-
|
446
|
+
--
|
415
447
|
|
416
|
-
|
448
|
+
##### [complex_find](https://github.com/appium/ruby_lib/blob/5a3ecbb4147693ce3c2c6b693e64074022d03511/lib/appium_lib/device/device.rb#L48)
|
417
449
|
|
418
|
-
|
450
|
+
> def complex_find
|
419
451
|
|
420
|
-
|
452
|
+
Find an element by a complex array of criteria. Available criteria
|
453
|
+
are listed in [link here]. Criteria are formed by creating an array
|
454
|
+
of arrays, each containing a selector and that selector's value.
|
421
455
|
|
422
|
-
|
456
|
+
```ruby
|
457
|
+
complex_find [[[2, 'Sau'], [14, true]]] # => Find a clickable element
|
458
|
+
# whose names starts with 'Sau'
|
459
|
+
```
|
423
460
|
|
424
|
-
|
425
|
-
The last button is considered "accept."
|
461
|
+
__Parameters:__
|
426
462
|
|
427
|
-
|
463
|
+
[Symbol] mod - If present, will be the 0th element in the selector array.
|
428
464
|
|
429
|
-
[
|
465
|
+
[Array<Object>] selectors - The selectors to find elements with.
|
430
466
|
|
431
467
|
--
|
432
468
|
|
433
|
-
##### [
|
469
|
+
##### [hide_keyboard](https://github.com/appium/ruby_lib/blob/5a3ecbb4147693ce3c2c6b693e64074022d03511/lib/appium_lib/device/device.rb#L60)
|
434
470
|
|
435
|
-
> def
|
471
|
+
> def hide_keyboard
|
436
472
|
|
437
|
-
|
438
|
-
The first button is considered "dismiss."
|
473
|
+
Hide the onscreen keyboard
|
439
474
|
|
440
|
-
|
475
|
+
__Parameters:__
|
441
476
|
|
442
|
-
[
|
477
|
+
[String] close_key - the name of the key which closes the keyboard.
|
478
|
+
Defaults to 'Done'.
|
443
479
|
|
444
480
|
--
|
445
481
|
|
446
|
-
##### [
|
482
|
+
##### [key_event](https://github.com/appium/ruby_lib/blob/5a3ecbb4147693ce3c2c6b693e64074022d03511/lib/appium_lib/device/device.rb#L69)
|
447
483
|
|
448
|
-
> def
|
484
|
+
> def key_event
|
449
485
|
|
450
|
-
|
451
|
-
The first button is considered "dismiss."
|
486
|
+
Send a key event to the device.
|
452
487
|
|
453
|
-
|
488
|
+
__Parameters:__
|
454
489
|
|
455
|
-
[
|
490
|
+
[integer] key - The key to send.
|
491
|
+
|
492
|
+
[String] metastate - The state the metakeys should be in when sending the key.
|
456
493
|
|
457
494
|
--
|
458
495
|
|
459
|
-
##### [
|
496
|
+
##### [push_file](https://github.com/appium/ruby_lib/blob/5a3ecbb4147693ce3c2c6b693e64074022d03511/lib/appium_lib/device/device.rb#L74)
|
460
497
|
|
461
|
-
> def
|
498
|
+
> def push_file
|
462
499
|
|
463
|
-
|
464
|
-
in this order: EditText, Button, ImageButton
|
500
|
+
Place a file in a specific location on the device.
|
465
501
|
|
466
502
|
__Parameters:__
|
467
503
|
|
468
|
-
[String]
|
469
|
-
|
470
|
-
__Returns:__
|
504
|
+
[String] path - The absolute path on the device to store data at.
|
471
505
|
|
472
|
-
[
|
506
|
+
[String] data - Raw file data to be sent to the device.
|
473
507
|
|
474
508
|
--
|
475
509
|
|
476
|
-
##### [
|
510
|
+
##### [pull_file](https://github.com/appium/ruby_lib/blob/5a3ecbb4147693ce3c2c6b693e64074022d03511/lib/appium_lib/device/device.rb#L79)
|
477
511
|
|
478
|
-
> def
|
512
|
+
> def pull_file
|
479
513
|
|
480
|
-
|
514
|
+
Retrieve a file from the device. This can retrieve an absolute path or
|
515
|
+
a path relative to the installed app (iOS only).
|
516
|
+
```ruby
|
517
|
+
pull_file '/local/data/some/path' #=> Get the file at that path
|
518
|
+
pull_file 'Shenanigans.app/some/file' #=> Get 'some/file' from the install location of Shenanigans.app
|
519
|
+
```
|
481
520
|
|
482
521
|
__Parameters:__
|
483
522
|
|
484
|
-
[String]
|
485
|
-
|
486
|
-
__Returns:__
|
487
|
-
|
488
|
-
[Element] the first matching element
|
523
|
+
[String] path - Either an absolute path OR, for iOS devices, a path relative to the app, as described.
|
489
524
|
|
490
525
|
--
|
491
526
|
|
492
|
-
##### [
|
493
|
-
|
494
|
-
> def texts text
|
527
|
+
##### [extend_search_contexts](https://github.com/appium/ruby_lib/blob/5a3ecbb4147693ce3c2c6b693e64074022d03511/lib/appium_lib/device/device.rb#L277)
|
495
528
|
|
496
|
-
|
529
|
+
> def extend_search_contexts
|
497
530
|
|
498
|
-
__Parameters:__
|
499
531
|
|
500
|
-
[String] text - the text to search for
|
501
532
|
|
502
|
-
|
533
|
+
--
|
503
534
|
|
504
|
-
|
535
|
+
##### [accessiblity_id_find](https://github.com/appium/ruby_lib/blob/5a3ecbb4147693ce3c2c6b693e64074022d03511/lib/appium_lib/device/device.rb#L277)
|
505
536
|
|
506
|
-
|
537
|
+
> def accessiblity_id_find
|
507
538
|
|
508
|
-
|
539
|
+
find_element/s with their accessibility_id
|
509
540
|
|
510
|
-
|
541
|
+
```ruby
|
542
|
+
find_elements :accessibility_id, 'Animation'
|
543
|
+
```
|
511
544
|
|
512
|
-
|
513
|
-
on Android name is content description
|
514
|
-
on iOS name is the accessibility label or the text.
|
545
|
+
--
|
515
546
|
|
516
|
-
|
547
|
+
##### [add_touch_actions](https://github.com/appium/ruby_lib/blob/5a3ecbb4147693ce3c2c6b693e64074022d03511/lib/appium_lib/device/device.rb#L283)
|
517
548
|
|
518
|
-
|
549
|
+
> def add_touch_actions
|
519
550
|
|
520
|
-
__Returns:__
|
521
551
|
|
522
|
-
[Element] the first matching element
|
523
552
|
|
524
553
|
--
|
525
554
|
|
526
|
-
##### [
|
555
|
+
##### [current_context=](https://github.com/appium/ruby_lib/blob/5a3ecbb4147693ce3c2c6b693e64074022d03511/lib/appium_lib/device/device.rb#L307)
|
527
556
|
|
528
|
-
> def
|
557
|
+
> def current_context=
|
529
558
|
|
530
|
-
|
531
|
-
|
532
|
-
|
559
|
+
Change the context to the given context.
|
560
|
+
```ruby
|
561
|
+
current_context= "NATIVE_APP"
|
562
|
+
```
|
533
563
|
|
534
564
|
__Parameters:__
|
535
565
|
|
536
|
-
[String]
|
537
|
-
|
538
|
-
__Returns:__
|
539
|
-
|
540
|
-
[Element] the first matching element
|
566
|
+
[String] The - context to change to
|
541
567
|
|
542
568
|
--
|
543
569
|
|
544
|
-
##### [
|
570
|
+
##### [current_context](https://github.com/appium/ruby_lib/blob/5a3ecbb4147693ce3c2c6b693e64074022d03511/lib/appium_lib/device/device.rb#L315)
|
545
571
|
|
546
|
-
> def
|
572
|
+
> def current_context
|
547
573
|
|
548
|
-
Return all elements matching name.
|
549
|
-
on Android name is content description
|
550
|
-
on iOS name is the accessibility label or the text.
|
551
574
|
|
552
|
-
__Parameters:__
|
553
|
-
|
554
|
-
[String] name - the name to search for
|
555
575
|
|
556
576
|
__Returns:__
|
557
577
|
|
558
|
-
[
|
578
|
+
[String] The context currently being used.
|
559
579
|
|
560
580
|
--
|
561
581
|
|
562
|
-
##### [
|
563
|
-
|
564
|
-
> def scroll_to text
|
582
|
+
##### [available_contexts](https://github.com/appium/ruby_lib/blob/5a3ecbb4147693ce3c2c6b693e64074022d03511/lib/appium_lib/device/device.rb#L318)
|
565
583
|
|
566
|
-
|
584
|
+
> def available_contexts
|
567
585
|
|
568
|
-
__Parameters:__
|
569
586
|
|
570
|
-
[String] text - the text to search for in the text value and content description
|
571
587
|
|
572
588
|
__Returns:__
|
573
589
|
|
574
|
-
[
|
590
|
+
[Array<String>] All usable contexts, as an array of strings.
|
575
591
|
|
576
592
|
--
|
577
593
|
|
578
|
-
##### [
|
594
|
+
##### [within_context](https://github.com/appium/ruby_lib/blob/5a3ecbb4147693ce3c2c6b693e64074022d03511/lib/appium_lib/device/device.rb#L328)
|
579
595
|
|
580
|
-
> def
|
596
|
+
> def within_context(context)
|
581
597
|
|
582
|
-
|
598
|
+
Perform a block within the given context, then switch back to the starting context.
|
599
|
+
```ruby
|
600
|
+
within_context('NATIVE_APP') do
|
601
|
+
find_element [:tag, "button"]
|
602
|
+
```
|
583
603
|
|
584
604
|
__Parameters:__
|
585
605
|
|
586
|
-
[String]
|
587
|
-
|
588
|
-
__Returns:__
|
589
|
-
|
590
|
-
[Element] the element scrolled to
|
606
|
+
[String] context - The context to switch to for the duration of the block.
|
591
607
|
|
592
608
|
--
|
593
609
|
|
594
|
-
##### [
|
595
|
-
|
596
|
-
> def textfields
|
610
|
+
##### [switch_to_default_context](https://github.com/appium/ruby_lib/blob/5a3ecbb4147693ce3c2c6b693e64074022d03511/lib/appium_lib/device/device.rb#L335)
|
597
611
|
|
598
|
-
|
612
|
+
> def switch_to_default_context
|
599
613
|
|
600
|
-
|
601
|
-
|
602
|
-
[Array<String>]
|
614
|
+
Change to the default context. This is equivalent to `current_context= nil`.
|
603
615
|
|
604
616
|
--
|
605
617
|
|
606
|
-
##### [
|
618
|
+
##### [pinch](https://github.com/appium/ruby_lib/blob/5a3ecbb4147693ce3c2c6b693e64074022d03511/lib/appium_lib/device/multi_touch.rb#L30)
|
607
619
|
|
608
|
-
> def
|
620
|
+
> def pinch(percentage=25, auto_perform=true)
|
621
|
+
|
622
|
+
Convenience method for pinching the screen.
|
623
|
+
Places two fingers at the edges of the screen and brings them together.
|
624
|
+
```ruby
|
625
|
+
action = pinch 75 #=> Pinch the screen from the top right and bottom left corners
|
626
|
+
action.perform #=> to 25% of its size.
|
627
|
+
```
|
609
628
|
|
610
|
-
|
629
|
+
__Parameters:__
|
611
630
|
|
612
|
-
|
631
|
+
[int] percentage - The percent size by which to shrink the screen when pinched.
|
613
632
|
|
614
|
-
[
|
633
|
+
[boolean] auto_perform - Whether to perform the action immediately (default true)
|
615
634
|
|
616
635
|
--
|
617
636
|
|
618
|
-
##### [
|
637
|
+
##### [zoom](https://github.com/appium/ruby_lib/blob/5a3ecbb4147693ce3c2c6b693e64074022d03511/lib/appium_lib/device/multi_touch.rb#L58)
|
619
638
|
|
620
|
-
> def
|
639
|
+
> def zoom(percentage=200, auto_perform=true)
|
621
640
|
|
622
|
-
|
641
|
+
Convenience method for zooming the screen.
|
642
|
+
Places two fingers at the edges of the screen and brings them together.
|
643
|
+
```ruby
|
644
|
+
action = zoom 200 #=> Zoom in the screen from the center until it doubles in size.
|
645
|
+
action.perform
|
646
|
+
```
|
623
647
|
|
624
|
-
|
648
|
+
__Parameters:__
|
649
|
+
|
650
|
+
[int] percentage - The percent size by which to shrink the screen when pinched.
|
625
651
|
|
626
|
-
[
|
652
|
+
[boolean] auto_perform - Whether to perform the action immediately (default true)
|
627
653
|
|
628
654
|
--
|
629
655
|
|
630
|
-
##### [
|
656
|
+
##### [initialize](https://github.com/appium/ruby_lib/blob/5a3ecbb4147693ce3c2c6b693e64074022d03511/lib/appium_lib/device/multi_touch.rb#L79)
|
631
657
|
|
632
|
-
> def
|
658
|
+
> def initialize
|
633
659
|
|
634
|
-
|
660
|
+
Create a new multi-action
|
635
661
|
|
636
662
|
__Returns:__
|
637
663
|
|
638
|
-
[
|
664
|
+
[MultiTouch] a new instance of MultiTouch
|
639
665
|
|
640
666
|
--
|
641
667
|
|
642
|
-
##### [
|
668
|
+
##### [add](https://github.com/appium/ruby_lib/blob/5a3ecbb4147693ce3c2c6b693e64074022d03511/lib/appium_lib/device/multi_touch.rb#L85)
|
643
669
|
|
644
|
-
> def
|
670
|
+
> def add(chain)
|
645
671
|
|
646
|
-
|
672
|
+
Add a touch_action to be performed
|
647
673
|
|
648
674
|
__Parameters:__
|
649
675
|
|
650
|
-
[
|
651
|
-
|
652
|
-
__Returns:__
|
653
|
-
|
654
|
-
[Textfield]
|
676
|
+
[TouchAction] chain - The action to add to the chain
|
655
677
|
|
656
678
|
--
|
657
679
|
|
658
|
-
##### [
|
680
|
+
##### [perform](https://github.com/appium/ruby_lib/blob/5a3ecbb4147693ce3c2c6b693e64074022d03511/lib/appium_lib/device/multi_touch.rb#L90)
|
659
681
|
|
660
|
-
> def
|
682
|
+
> def perform
|
661
683
|
|
662
|
-
|
684
|
+
Ask Appium to perform the actions
|
663
685
|
|
664
|
-
|
686
|
+
--
|
665
687
|
|
666
|
-
|
688
|
+
##### [ACTIONS](https://github.com/appium/ruby_lib/blob/5a3ecbb4147693ce3c2c6b693e64074022d03511/lib/appium_lib/device/touch_actions.rb#L12)
|
689
|
+
|
690
|
+
> ACTIONS = [:move_to, :press_for_duration, :press, :release, :tap, :wait, :perform]
|
667
691
|
|
668
|
-
__Returns:__
|
669
692
|
|
670
|
-
[Textfield]
|
671
693
|
|
672
694
|
--
|
673
695
|
|
674
|
-
##### [
|
696
|
+
##### [COMPLEX_ACTIONS](https://github.com/appium/ruby_lib/blob/5a3ecbb4147693ce3c2c6b693e64074022d03511/lib/appium_lib/device/touch_actions.rb#L13)
|
675
697
|
|
676
|
-
>
|
698
|
+
> COMPLEX_ACTIONS = [:swipe]
|
677
699
|
|
678
|
-
Check every 0.5 seconds to see if block.call doesn't raise an exception.
|
679
|
-
if .call raises an exception then it will be tried again.
|
680
|
-
if .call doesn't raise an exception then it will stop waiting.
|
681
700
|
|
682
|
-
Example: wait { name('back').click }
|
683
701
|
|
684
|
-
|
702
|
+
--
|
685
703
|
|
686
|
-
|
704
|
+
##### [actions](https://github.com/appium/ruby_lib/blob/5a3ecbb4147693ce3c2c6b693e64074022d03511/lib/appium_lib/device/touch_actions.rb#L27)
|
687
705
|
|
688
|
-
|
689
|
-
Note that max wait 0 means infinity.
|
706
|
+
> def actions
|
690
707
|
|
691
|
-
|
708
|
+
Returns the value of attribute actions
|
692
709
|
|
693
|
-
|
710
|
+
--
|
694
711
|
|
695
|
-
|
712
|
+
##### [initialize](https://github.com/appium/ruby_lib/blob/5a3ecbb4147693ce3c2c6b693e64074022d03511/lib/appium_lib/device/touch_actions.rb#L29)
|
696
713
|
|
697
|
-
|
714
|
+
> def initialize
|
698
715
|
|
699
|
-
--
|
700
716
|
|
701
|
-
##### [ignore](https://github.com/appium/ruby_lib/blob/a07da28de1e7133c77070859c2c35d7bd2635684/lib/appium_lib/common/helper.rb#L45)
|
702
717
|
|
703
|
-
|
718
|
+
__Returns:__
|
704
719
|
|
705
|
-
|
720
|
+
[TouchAction] a new instance of TouchAction
|
706
721
|
|
707
722
|
--
|
708
723
|
|
709
|
-
##### [
|
724
|
+
##### [move_to](https://github.com/appium/ruby_lib/blob/5a3ecbb4147693ce3c2c6b693e64074022d03511/lib/appium_lib/device/touch_actions.rb#L37)
|
710
725
|
|
711
|
-
> def
|
726
|
+
> def move_to(opts)
|
712
727
|
|
713
|
-
|
714
|
-
Give up after 30 seconds.
|
728
|
+
Move to the given co-ordinates.
|
715
729
|
|
716
730
|
__Parameters:__
|
717
731
|
|
718
|
-
[
|
719
|
-
|
720
|
-
[Float] interval - the time in seconds to wait after calling the block
|
721
|
-
|
722
|
-
[Block] block - the block to call
|
723
|
-
|
724
|
-
__Returns:__
|
725
|
-
|
726
|
-
[Object] the result of block.call
|
732
|
+
[Hash] opts - a customizable set of options
|
727
733
|
|
728
734
|
--
|
729
735
|
|
730
|
-
##### [
|
736
|
+
##### [press_for_duration](https://github.com/appium/ruby_lib/blob/5a3ecbb4147693ce3c2c6b693e64074022d03511/lib/appium_lib/device/touch_actions.rb#L47)
|
731
737
|
|
732
|
-
> def
|
733
|
-
|
734
|
-
Navigate back.
|
738
|
+
> def press_for_duration(element, x, y, duration)
|
735
739
|
|
736
|
-
|
740
|
+
Press down for a specific duration.
|
737
741
|
|
738
|
-
|
742
|
+
__Parameters:__
|
739
743
|
|
740
|
-
|
744
|
+
[WebDriver::Element] element - the element to press.
|
741
745
|
|
742
|
-
|
746
|
+
[integer] x - x co-ordinate to press on.
|
743
747
|
|
744
|
-
|
748
|
+
[integer] y - y co-ordinate to press on.
|
745
749
|
|
746
|
-
|
750
|
+
[integer] duration - Number of seconds to press.
|
747
751
|
|
748
752
|
--
|
749
753
|
|
750
|
-
##### [
|
754
|
+
##### [press](https://github.com/appium/ruby_lib/blob/5a3ecbb4147693ce3c2c6b693e64074022d03511/lib/appium_lib/device/touch_actions.rb#L58)
|
751
755
|
|
752
|
-
> def
|
756
|
+
> def press(opts)
|
753
757
|
|
754
|
-
|
758
|
+
Press a finger onto the screen. Finger will stay down until you call
|
759
|
+
`release`.
|
755
760
|
|
756
761
|
__Parameters:__
|
757
762
|
|
758
|
-
[
|
759
|
-
|
760
|
-
__Returns:__
|
761
|
-
|
762
|
-
[Element]
|
763
|
+
[Hash] opts - a customizable set of options
|
763
764
|
|
764
765
|
--
|
765
766
|
|
766
|
-
##### [
|
767
|
+
##### [release](https://github.com/appium/ruby_lib/blob/5a3ecbb4147693ce3c2c6b693e64074022d03511/lib/appium_lib/device/touch_actions.rb#L69)
|
767
768
|
|
768
|
-
> def
|
769
|
+
> def release(opts=nil)
|
769
770
|
|
770
|
-
|
771
|
+
Remove a finger from the screen.
|
771
772
|
|
772
773
|
__Parameters:__
|
773
774
|
|
774
|
-
[
|
775
|
-
|
776
|
-
__Returns:__
|
777
|
-
|
778
|
-
[Array<Element>]
|
775
|
+
[Hash] opts - a customizable set of options
|
779
776
|
|
780
777
|
--
|
781
778
|
|
782
|
-
##### [
|
779
|
+
##### [tap](https://github.com/appium/ruby_lib/blob/5a3ecbb4147693ce3c2c6b693e64074022d03511/lib/appium_lib/device/touch_actions.rb#L80)
|
783
780
|
|
784
|
-
> def
|
781
|
+
> def tap(opts)
|
785
782
|
|
786
|
-
|
783
|
+
Touch a point on the screen
|
787
784
|
|
788
785
|
__Parameters:__
|
789
786
|
|
790
|
-
[
|
791
|
-
|
792
|
-
[Integer] index - the index
|
793
|
-
|
794
|
-
__Returns:__
|
795
|
-
|
796
|
-
[Element] the found element of type tag_name
|
787
|
+
[Hash] opts - a customizable set of options
|
797
788
|
|
798
789
|
--
|
799
790
|
|
800
|
-
##### [
|
791
|
+
##### [wait](https://github.com/appium/ruby_lib/blob/5a3ecbb4147693ce3c2c6b693e64074022d03511/lib/appium_lib/device/touch_actions.rb#L88)
|
801
792
|
|
802
|
-
> def
|
793
|
+
> def wait(seconds)
|
803
794
|
|
804
|
-
|
795
|
+
Pause for a number of seconds before the next action
|
805
796
|
|
806
797
|
__Parameters:__
|
807
798
|
|
808
|
-
[
|
809
|
-
|
810
|
-
__Returns:__
|
811
|
-
|
812
|
-
[Array<Element>] the found elements of type tag_name
|
799
|
+
[integer] seconds - Number of seconds to pause for
|
813
800
|
|
814
801
|
--
|
815
802
|
|
816
|
-
##### [
|
803
|
+
##### [swipe](https://github.com/appium/ruby_lib/blob/5a3ecbb4147693ce3c2c6b693e64074022d03511/lib/appium_lib/device/touch_actions.rb#L99)
|
817
804
|
|
818
|
-
> def
|
805
|
+
> def swipe(opts)
|
819
806
|
|
820
|
-
|
807
|
+
Convenience method to peform a swipe.
|
821
808
|
|
822
809
|
__Parameters:__
|
823
810
|
|
824
|
-
[
|
811
|
+
[Hash] opts - a customizable set of options
|
812
|
+
|
813
|
+
--
|
825
814
|
|
826
|
-
|
815
|
+
##### [perform](https://github.com/appium/ruby_lib/blob/5a3ecbb4147693ce3c2c6b693e64074022d03511/lib/appium_lib/device/touch_actions.rb#L114)
|
827
816
|
|
828
|
-
|
817
|
+
> def perform
|
829
818
|
|
830
|
-
|
819
|
+
Ask the driver to perform all actions in this action chain.
|
831
820
|
|
832
821
|
--
|
833
822
|
|
834
|
-
##### [
|
823
|
+
##### [cancel](https://github.com/appium/ruby_lib/blob/5a3ecbb4147693ce3c2c6b693e64074022d03511/lib/appium_lib/device/touch_actions.rb#L120)
|
835
824
|
|
836
|
-
> def
|
825
|
+
> def cancel
|
837
826
|
|
838
|
-
|
827
|
+
Does nothing, currently.
|
839
828
|
|
840
|
-
|
829
|
+
--
|
841
830
|
|
842
|
-
|
831
|
+
##### [chain_method](https://github.com/appium/ruby_lib/blob/5a3ecbb4147693ce3c2c6b693e64074022d03511/lib/appium_lib/device/touch_actions.rb#L128)
|
843
832
|
|
844
|
-
|
833
|
+
> def chain_method(method, args=nil)
|
845
834
|
|
846
|
-
__Returns:__
|
847
835
|
|
848
|
-
[Array<Element>] the elements of type tag exactly matching text
|
849
836
|
|
850
837
|
--
|
851
838
|
|
852
|
-
##### [
|
839
|
+
##### [args_with_ele_ref](https://github.com/appium/ruby_lib/blob/5a3ecbb4147693ce3c2c6b693e64074022d03511/lib/appium_lib/device/touch_actions.rb#L137)
|
853
840
|
|
854
|
-
> def
|
841
|
+
> def args_with_ele_ref(args)
|
855
842
|
|
856
|
-
Get the first tag by attribute that exactly matches value.
|
857
843
|
|
858
|
-
__Parameters:__
|
859
844
|
|
860
|
-
|
845
|
+
--
|
861
846
|
|
862
|
-
|
847
|
+
##### [wait](https://github.com/appium/ruby_lib/blob/5a3ecbb4147693ce3c2c6b693e64074022d03511/lib/appium_lib/common/helper.rb#L33)
|
863
848
|
|
864
|
-
|
849
|
+
> def wait max_wait=30, interval=0.5, &block
|
865
850
|
|
866
|
-
|
851
|
+
Check every 0.5 seconds to see if block.call doesn't raise an exception.
|
852
|
+
if .call raises an exception then it will be tried again.
|
853
|
+
if .call doesn't raise an exception then it will stop waiting.
|
867
854
|
|
868
|
-
|
855
|
+
Example: wait { name('back').click }
|
869
856
|
|
870
|
-
|
857
|
+
Give up after 30 seconds.
|
858
|
+
|
859
|
+
__Parameters:__
|
871
860
|
|
872
|
-
|
861
|
+
[Integer] max_wait - the maximum time in seconds to wait for.
|
862
|
+
Note that max wait 0 means infinity.
|
873
863
|
|
874
|
-
|
864
|
+
[Float] interval - the time in seconds to wait after calling the block
|
875
865
|
|
876
|
-
|
866
|
+
[Block] block - the block to call
|
877
867
|
|
878
|
-
|
868
|
+
__Returns:__
|
879
869
|
|
880
|
-
[
|
870
|
+
[Object] the result of block.call
|
881
871
|
|
882
|
-
|
872
|
+
--
|
883
873
|
|
884
|
-
|
874
|
+
##### [ignore](https://github.com/appium/ruby_lib/blob/5a3ecbb4147693ce3c2c6b693e64074022d03511/lib/appium_lib/common/helper.rb#L49)
|
885
875
|
|
886
|
-
|
876
|
+
> def ignore &block
|
887
877
|
|
888
|
-
|
878
|
+
Return block.call and ignore any exceptions.
|
889
879
|
|
890
880
|
--
|
891
881
|
|
892
|
-
##### [
|
882
|
+
##### [wait_true](https://github.com/appium/ruby_lib/blob/5a3ecbb4147693ce3c2c6b693e64074022d03511/lib/appium_lib/common/helper.rb#L64)
|
893
883
|
|
894
|
-
> def
|
884
|
+
> def wait_true max_wait=30, interval=0.5, &block
|
895
885
|
|
896
|
-
|
897
|
-
|
886
|
+
Check every 0.5 seconds to see if block.call returns a truthy value.
|
887
|
+
Note this isn't a strict boolean true, any truthy value is accepted.
|
888
|
+
false and nil are considered failures.
|
889
|
+
Give up after 30 seconds.
|
898
890
|
|
899
891
|
__Parameters:__
|
900
892
|
|
901
|
-
[
|
893
|
+
[Integer] max_wait - the maximum time in seconds to wait for
|
894
|
+
|
895
|
+
[Float] interval - the time in seconds to wait after calling the block
|
902
896
|
|
903
|
-
[
|
897
|
+
[Block] block - the block to call
|
904
898
|
|
905
899
|
__Returns:__
|
906
900
|
|
907
|
-
[
|
901
|
+
[Object] the result of block.call
|
908
902
|
|
909
903
|
--
|
910
904
|
|
911
|
-
##### [
|
905
|
+
##### [back](https://github.com/appium/ruby_lib/blob/5a3ecbb4147693ce3c2c6b693e64074022d03511/lib/appium_lib/common/helper.rb#L81)
|
912
906
|
|
913
|
-
> def
|
907
|
+
> def back
|
914
908
|
|
915
|
-
|
916
|
-
element.attribute(:text).include? text
|
909
|
+
Navigate back.
|
917
910
|
|
918
|
-
|
911
|
+
__Returns:__
|
919
912
|
|
920
|
-
[
|
913
|
+
[void]
|
921
914
|
|
922
|
-
|
915
|
+
--
|
923
916
|
|
924
|
-
|
917
|
+
##### [session_id](https://github.com/appium/ruby_lib/blob/5a3ecbb4147693ce3c2c6b693e64074022d03511/lib/appium_lib/common/helper.rb#L86)
|
925
918
|
|
926
|
-
|
919
|
+
> def session_id
|
920
|
+
|
921
|
+
For Sauce Labs reporting. Returns the current session id.
|
927
922
|
|
928
923
|
--
|
929
924
|
|
930
|
-
##### [
|
925
|
+
##### [xpath](https://github.com/appium/ruby_lib/blob/5a3ecbb4147693ce3c2c6b693e64074022d03511/lib/appium_lib/common/helper.rb#L94)
|
931
926
|
|
932
|
-
> def
|
927
|
+
> def xpath xpath_str
|
933
928
|
|
934
|
-
|
929
|
+
Returns the first element that matches the provided xpath.
|
935
930
|
|
936
931
|
__Parameters:__
|
937
932
|
|
938
|
-
[String]
|
933
|
+
[String] xpath_str - the XPath string
|
939
934
|
|
940
935
|
__Returns:__
|
941
936
|
|
@@ -943,27 +938,27 @@ __Returns:__
|
|
943
938
|
|
944
939
|
--
|
945
940
|
|
946
|
-
##### [
|
941
|
+
##### [xpaths](https://github.com/appium/ruby_lib/blob/5a3ecbb4147693ce3c2c6b693e64074022d03511/lib/appium_lib/common/helper.rb#L102)
|
947
942
|
|
948
|
-
> def
|
943
|
+
> def xpaths xpath_str
|
949
944
|
|
950
|
-
|
945
|
+
Returns all elements that match the provided xpath.
|
951
946
|
|
952
947
|
__Parameters:__
|
953
948
|
|
954
|
-
[String]
|
949
|
+
[String] xpath_str - the XPath string
|
955
950
|
|
956
951
|
__Returns:__
|
957
952
|
|
958
|
-
[Element]
|
953
|
+
[Array<Element>]
|
959
954
|
|
960
955
|
--
|
961
956
|
|
962
|
-
##### [source](https://github.com/appium/ruby_lib/blob/
|
957
|
+
##### [source](https://github.com/appium/ruby_lib/blob/5a3ecbb4147693ce3c2c6b693e64074022d03511/lib/appium_lib/common/helper.rb#L108)
|
963
958
|
|
964
959
|
> def source
|
965
960
|
|
966
|
-
Prints
|
961
|
+
Prints xml of the current page
|
967
962
|
|
968
963
|
__Returns:__
|
969
964
|
|
@@ -971,83 +966,81 @@ __Returns:__
|
|
971
966
|
|
972
967
|
--
|
973
968
|
|
974
|
-
##### [get_source](https://github.com/appium/ruby_lib/blob/
|
969
|
+
##### [get_source](https://github.com/appium/ruby_lib/blob/5a3ecbb4147693ce3c2c6b693e64074022d03511/lib/appium_lib/common/helper.rb#L118)
|
975
970
|
|
976
971
|
> def get_source
|
977
972
|
|
978
|
-
|
973
|
+
Returns XML string for the current page
|
974
|
+
Same as driver.page_source
|
979
975
|
|
980
976
|
__Returns:__
|
981
977
|
|
982
|
-
[
|
978
|
+
[String]
|
983
979
|
|
984
980
|
--
|
985
981
|
|
986
|
-
##### [
|
982
|
+
##### [result](https://github.com/appium/ruby_lib/blob/5a3ecbb4147693ce3c2c6b693e64074022d03511/lib/appium_lib/common/helper.rb#L125)
|
987
983
|
|
988
|
-
> def
|
984
|
+
> def result
|
989
985
|
|
990
|
-
Returns the
|
986
|
+
Returns the value of attribute result
|
991
987
|
|
992
|
-
|
988
|
+
--
|
993
989
|
|
994
|
-
|
990
|
+
##### [initialize](https://github.com/appium/ruby_lib/blob/5a3ecbb4147693ce3c2c6b693e64074022d03511/lib/appium_lib/common/helper.rb#L127)
|
995
991
|
|
996
|
-
|
992
|
+
> def initialize
|
997
993
|
|
998
|
-
[Element]
|
999
994
|
|
1000
|
-
--
|
1001
995
|
|
1002
|
-
|
996
|
+
__Returns:__
|
1003
997
|
|
1004
|
-
|
998
|
+
[CountElements] a new instance of CountElements
|
1005
999
|
|
1006
|
-
|
1000
|
+
--
|
1007
1001
|
|
1008
|
-
|
1002
|
+
##### [reset](https://github.com/appium/ruby_lib/blob/5a3ecbb4147693ce3c2c6b693e64074022d03511/lib/appium_lib/common/helper.rb#L131)
|
1009
1003
|
|
1010
|
-
|
1004
|
+
> def reset
|
1011
1005
|
|
1012
|
-
__Returns:__
|
1013
1006
|
|
1014
|
-
[Array<Element>]
|
1015
1007
|
|
1016
1008
|
--
|
1017
1009
|
|
1018
|
-
##### [
|
1010
|
+
##### [start_element](https://github.com/appium/ruby_lib/blob/5a3ecbb4147693ce3c2c6b693e64074022d03511/lib/appium_lib/common/helper.rb#L136)
|
1019
1011
|
|
1020
|
-
> def
|
1012
|
+
> def start_element name, attrs = []
|
1021
1013
|
|
1022
|
-
|
1014
|
+
http://nokogiri.org/Nokogiri/XML/SAX/Document.html
|
1023
1015
|
|
1024
|
-
|
1016
|
+
--
|
1025
1017
|
|
1026
|
-
|
1018
|
+
##### [formatted_result](https://github.com/appium/ruby_lib/blob/5a3ecbb4147693ce3c2c6b693e64074022d03511/lib/appium_lib/common/helper.rb#L140)
|
1019
|
+
|
1020
|
+
> def formatted_result
|
1027
1021
|
|
1028
|
-
__Returns:__
|
1029
1022
|
|
1030
|
-
[Element]
|
1031
1023
|
|
1032
1024
|
--
|
1033
1025
|
|
1034
|
-
##### [
|
1026
|
+
##### [get_page_class](https://github.com/appium/ruby_lib/blob/5a3ecbb4147693ce3c2c6b693e64074022d03511/lib/appium_lib/common/helper.rb#L151)
|
1035
1027
|
|
1036
|
-
> def
|
1028
|
+
> def get_page_class
|
1037
1029
|
|
1038
|
-
Returns
|
1030
|
+
Returns a string of class counts.
|
1039
1031
|
|
1040
|
-
|
1032
|
+
--
|
1041
1033
|
|
1042
|
-
|
1034
|
+
##### [page_class](https://github.com/appium/ruby_lib/blob/5a3ecbb4147693ce3c2c6b693e64074022d03511/lib/appium_lib/common/helper.rb#L162)
|
1043
1035
|
|
1044
|
-
|
1036
|
+
> def page_class
|
1045
1037
|
|
1046
|
-
|
1038
|
+
Count all classes on screen and print to stdout.
|
1039
|
+
Useful for appium_console.
|
1047
1040
|
|
1048
1041
|
--
|
1049
1042
|
|
1050
|
-
##### [px_to_window_rel](https://github.com/appium/ruby_lib/blob/
|
1043
|
+
##### [px_to_window_rel](https://github.com/appium/ruby_lib/blob/5a3ecbb4147693ce3c2c6b693e64074022d03511/lib/appium_lib/common/helper.rb#L172)
|
1051
1044
|
|
1052
1045
|
> def px_to_window_rel opts={}
|
1053
1046
|
|
@@ -1059,15 +1052,7 @@ px_to_window_rel x: 50, y: 150
|
|
1059
1052
|
|
1060
1053
|
--
|
1061
1054
|
|
1062
|
-
##### [
|
1063
|
-
|
1064
|
-
> def lazy_load_strings
|
1065
|
-
|
1066
|
-
|
1067
|
-
|
1068
|
-
--
|
1069
|
-
|
1070
|
-
##### [xml_keys](https://github.com/appium/ruby_lib/blob/a07da28de1e7133c77070859c2c35d7bd2635684/lib/appium_lib/common/helper.rb#L245)
|
1055
|
+
##### [xml_keys](https://github.com/appium/ruby_lib/blob/5a3ecbb4147693ce3c2c6b693e64074022d03511/lib/appium_lib/common/helper.rb#L189)
|
1071
1056
|
|
1072
1057
|
> def xml_keys target
|
1073
1058
|
|
@@ -1083,7 +1068,7 @@ __Returns:__
|
|
1083
1068
|
|
1084
1069
|
--
|
1085
1070
|
|
1086
|
-
##### [xml_values](https://github.com/appium/ruby_lib/blob/
|
1071
|
+
##### [xml_values](https://github.com/appium/ruby_lib/blob/5a3ecbb4147693ce3c2c6b693e64074022d03511/lib/appium_lib/common/helper.rb#L197)
|
1087
1072
|
|
1088
1073
|
> def xml_values target
|
1089
1074
|
|
@@ -1099,7 +1084,7 @@ __Returns:__
|
|
1099
1084
|
|
1100
1085
|
--
|
1101
1086
|
|
1102
|
-
##### [resolve_id](https://github.com/appium/ruby_lib/blob/
|
1087
|
+
##### [resolve_id](https://github.com/appium/ruby_lib/blob/5a3ecbb4147693ce3c2c6b693e64074022d03511/lib/appium_lib/common/helper.rb#L205)
|
1103
1088
|
|
1104
1089
|
> def resolve_id id
|
1105
1090
|
|
@@ -1115,402 +1100,502 @@ __Returns:__
|
|
1115
1100
|
|
1116
1101
|
--
|
1117
1102
|
|
1118
|
-
##### [
|
1103
|
+
##### [window_size](https://github.com/appium/ruby_lib/blob/5a3ecbb4147693ce3c2c6b693e64074022d03511/lib/appium_lib/common/element/window.rb#L5)
|
1119
1104
|
|
1120
|
-
> def
|
1105
|
+
> def window_size
|
1121
1106
|
|
1122
|
-
|
1107
|
+
Get the window's size
|
1123
1108
|
|
1124
1109
|
--
|
1125
1110
|
|
1126
|
-
##### [
|
1111
|
+
##### [result](https://github.com/appium/ruby_lib/blob/5a3ecbb4147693ce3c2c6b693e64074022d03511/lib/appium_lib/android/helper.rb#L7) android
|
1127
1112
|
|
1128
|
-
> def
|
1113
|
+
> def result
|
1129
1114
|
|
1130
|
-
|
1115
|
+
TODO: Support strings.xml ids
|
1131
1116
|
|
1132
|
-
|
1117
|
+
--
|
1118
|
+
|
1119
|
+
##### [keys](https://github.com/appium/ruby_lib/blob/5a3ecbb4147693ce3c2c6b693e64074022d03511/lib/appium_lib/android/helper.rb#L7) android
|
1120
|
+
|
1121
|
+
> def keys
|
1122
|
+
|
1123
|
+
TODO: Support strings.xml ids
|
1133
1124
|
|
1134
1125
|
--
|
1135
1126
|
|
1136
|
-
##### [
|
1127
|
+
##### [filter](https://github.com/appium/ruby_lib/blob/5a3ecbb4147693ce3c2c6b693e64074022d03511/lib/appium_lib/android/helper.rb#L9) android
|
1137
1128
|
|
1138
|
-
> def
|
1129
|
+
> def filter
|
1139
1130
|
|
1140
|
-
Returns the name attribute
|
1141
1131
|
|
1142
|
-
Fixes NoMethodError: undefined method `name' for Selenium::WebDriver::Element
|
1143
1132
|
|
1144
1133
|
--
|
1145
1134
|
|
1146
|
-
##### [
|
1135
|
+
##### [filter=](https://github.com/appium/ruby_lib/blob/5a3ecbb4147693ce3c2c6b693e64074022d03511/lib/appium_lib/android/helper.rb#L14) android
|
1147
1136
|
|
1148
|
-
> def
|
1137
|
+
> def filter= value
|
1149
1138
|
|
1150
|
-
|
1139
|
+
convert to string to support symbols
|
1140
|
+
|
1141
|
+
--
|
1142
|
+
|
1143
|
+
##### [initialize](https://github.com/appium/ruby_lib/blob/5a3ecbb4147693ce3c2c6b693e64074022d03511/lib/appium_lib/android/helper.rb#L20) android
|
1144
|
+
|
1145
|
+
> def initialize
|
1151
1146
|
|
1152
|
-
```ruby
|
1153
|
-
execute_script 'mobile: tap', :x => 0.0, :y => 0.98
|
1154
|
-
```
|
1155
1147
|
|
1156
|
-
https://github.com/appium/appium/wiki/Automating-mobile-gestures
|
1157
1148
|
|
1158
1149
|
__Returns:__
|
1159
1150
|
|
1160
|
-
[
|
1151
|
+
[AndroidElements] a new instance of AndroidElements
|
1161
1152
|
|
1162
1153
|
--
|
1163
1154
|
|
1164
|
-
##### [
|
1155
|
+
##### [reset](https://github.com/appium/ruby_lib/blob/5a3ecbb4147693ce3c2c6b693e64074022d03511/lib/appium_lib/android/helper.rb#L25) android
|
1165
1156
|
|
1166
|
-
>
|
1157
|
+
> def reset
|
1167
1158
|
|
1168
1159
|
|
1169
1160
|
|
1170
1161
|
--
|
1171
1162
|
|
1172
|
-
##### [
|
1173
|
-
|
1174
|
-
> def awesome_openstruct target
|
1163
|
+
##### [start_element](https://github.com/appium/ruby_lib/blob/5a3ecbb4147693ce3c2c6b693e64074022d03511/lib/appium_lib/android/helper.rb#L31) android
|
1175
1164
|
|
1165
|
+
> def start_element name, attrs = []
|
1176
1166
|
|
1167
|
+
http://nokogiri.org/Nokogiri/XML/SAX/Document.html
|
1177
1168
|
|
1178
1169
|
--
|
1179
1170
|
|
1180
|
-
##### [
|
1171
|
+
##### [get_android_inspect](https://github.com/appium/ruby_lib/blob/5a3ecbb4147693ce3c2c6b693e64074022d03511/lib/appium_lib/android/helper.rb#L65) android
|
1181
1172
|
|
1182
|
-
> def
|
1173
|
+
> def get_android_inspect class_name=false
|
1183
1174
|
|
1184
|
-
|
1185
|
-
|
1175
|
+
Android only.
|
1176
|
+
Returns a string containing interesting elements.
|
1177
|
+
The text, content description, and id are returned.
|
1178
|
+
if false (default) then all classes will be inspected
|
1186
1179
|
|
1187
1180
|
__Parameters:__
|
1188
1181
|
|
1189
|
-
[
|
1182
|
+
[String] class_name - the class name to filter on.
|
1190
1183
|
|
1191
1184
|
__Returns:__
|
1192
1185
|
|
1193
|
-
[
|
1186
|
+
[String]
|
1194
1187
|
|
1195
1188
|
--
|
1196
1189
|
|
1197
|
-
##### [
|
1198
|
-
|
1199
|
-
> def self.promote_singleton_appium_methods main_module
|
1190
|
+
##### [page](https://github.com/appium/ruby_lib/blob/5a3ecbb4147693ce3c2c6b693e64074022d03511/lib/appium_lib/android/helper.rb#L80) android
|
1200
1191
|
|
1192
|
+
> def page class_name=false
|
1201
1193
|
|
1194
|
+
Intended for use with console.
|
1195
|
+
Inspects and prints the current page.
|
1196
|
+
if false (default) then all classes will be inspected
|
1202
1197
|
|
1203
|
-
|
1198
|
+
__Parameters:__
|
1204
1199
|
|
1205
|
-
|
1200
|
+
[String] class_name - the class name to filter on.
|
1206
1201
|
|
1207
|
-
|
1202
|
+
__Returns:__
|
1208
1203
|
|
1209
|
-
|
1204
|
+
[void]
|
1210
1205
|
|
1211
|
-
|
1206
|
+
--
|
1212
1207
|
|
1213
|
-
|
1214
|
-
Appium.promote_appium_methods Object
|
1215
|
-
```
|
1208
|
+
##### [current_app](https://github.com/appium/ruby_lib/blob/5a3ecbb4147693ce3c2c6b693e64074022d03511/lib/appium_lib/android/helper.rb#L88) android
|
1216
1209
|
|
1217
|
-
|
1210
|
+
> def current_app
|
1218
1211
|
|
1219
|
-
|
1212
|
+
Lists package, activity, and adb shell am start -n value for current app.
|
1213
|
+
Works on local host only (not remote).
|
1214
|
+
noinspection RubyArgCount
|
1220
1215
|
|
1221
1216
|
--
|
1222
1217
|
|
1223
|
-
##### [
|
1218
|
+
##### [id](https://github.com/appium/ruby_lib/blob/5a3ecbb4147693ce3c2c6b693e64074022d03511/lib/appium_lib/android/helper.rb#L102) android
|
1224
1219
|
|
1225
|
-
> def
|
1220
|
+
> def id id
|
1226
1221
|
|
1227
|
-
|
1228
|
-
|
1222
|
+
Find by id
|
1223
|
+
|
1224
|
+
__Parameters:__
|
1225
|
+
|
1226
|
+
[String] id - the id to search for
|
1229
1227
|
|
1230
1228
|
__Returns:__
|
1231
1229
|
|
1232
|
-
[
|
1230
|
+
[Element]
|
1233
1231
|
|
1234
1232
|
--
|
1235
1233
|
|
1236
|
-
##### [
|
1234
|
+
##### [ele_index](https://github.com/appium/ruby_lib/blob/5a3ecbb4147693ce3c2c6b693e64074022d03511/lib/appium_lib/android/helper.rb#L116) android
|
1237
1235
|
|
1238
|
-
> def
|
1236
|
+
> def ele_index class_name, index
|
1239
1237
|
|
1240
|
-
|
1238
|
+
Find the element of type class_name at matching index.
|
1241
1239
|
|
1242
|
-
|
1243
|
-
|
1244
|
-
##### [app_name](https://github.com/appium/ruby_lib/blob/a07da28de1e7133c77070859c2c35d7bd2635684/lib/appium_lib/driver.rb#L204)
|
1240
|
+
__Parameters:__
|
1245
1241
|
|
1246
|
-
|
1242
|
+
[String] class_name - the class name to find
|
1247
1243
|
|
1248
|
-
|
1244
|
+
[Integer] index - the index
|
1249
1245
|
|
1250
|
-
|
1246
|
+
__Returns:__
|
1251
1247
|
|
1252
|
-
|
1248
|
+
[Element] the found element of type class_name
|
1253
1249
|
|
1254
|
-
|
1250
|
+
--
|
1255
1251
|
|
1256
|
-
|
1252
|
+
##### [find_ele_by_attr](https://github.com/appium/ruby_lib/blob/5a3ecbb4147693ce3c2c6b693e64074022d03511/lib/appium_lib/android/helper.rb#L134) android
|
1257
1253
|
|
1258
|
-
|
1254
|
+
> def find_ele_by_attr class_name, attr, value
|
1259
1255
|
|
1260
|
-
|
1256
|
+
Find the first element exactly matching class and attribute value.
|
1261
1257
|
|
1262
|
-
|
1258
|
+
__Parameters:__
|
1263
1259
|
|
1264
|
-
|
1260
|
+
[String] class_name - the class name to search for
|
1265
1261
|
|
1266
|
-
|
1262
|
+
[String] attr - the attribute to inspect
|
1267
1263
|
|
1268
|
-
|
1264
|
+
[String] value - the expected value of the attribute
|
1269
1265
|
|
1270
|
-
|
1266
|
+
__Returns:__
|
1271
1267
|
|
1272
|
-
|
1268
|
+
[Element]
|
1273
1269
|
|
1274
1270
|
--
|
1275
1271
|
|
1276
|
-
##### [
|
1272
|
+
##### [find_eles_by_attr](https://github.com/appium/ruby_lib/blob/5a3ecbb4147693ce3c2c6b693e64074022d03511/lib/appium_lib/android/helper.rb#L143) android
|
1277
1273
|
|
1278
|
-
> def
|
1274
|
+
> def find_eles_by_attr class_name, attr, value
|
1279
1275
|
|
1280
|
-
|
1276
|
+
Find all elements exactly matching class and attribute value.
|
1281
1277
|
|
1282
|
-
|
1278
|
+
__Parameters:__
|
1283
1279
|
|
1284
|
-
|
1280
|
+
[String] class_name - the class name to match
|
1285
1281
|
|
1286
|
-
|
1282
|
+
[String] attr - the attribute to compare
|
1287
1283
|
|
1288
|
-
|
1284
|
+
[String] value - the value of the attribute that the element must have
|
1289
1285
|
|
1290
|
-
|
1286
|
+
__Returns:__
|
1291
1287
|
|
1292
|
-
|
1288
|
+
[Array<Element>]
|
1293
1289
|
|
1294
|
-
|
1290
|
+
--
|
1295
1291
|
|
1296
|
-
|
1292
|
+
##### [find_ele_by_attr_include](https://github.com/appium/ruby_lib/blob/5a3ecbb4147693ce3c2c6b693e64074022d03511/lib/appium_lib/android/helper.rb#L157) android
|
1297
1293
|
|
1298
|
-
|
1294
|
+
> def find_ele_by_attr_include class_name, attr, value
|
1299
1295
|
|
1300
|
-
|
1296
|
+
Find the first element by attribute that exactly matches value.
|
1301
1297
|
|
1302
|
-
|
1298
|
+
__Parameters:__
|
1299
|
+
|
1300
|
+
[String] class_name - the class name to match
|
1303
1301
|
|
1304
|
-
|
1302
|
+
[String] attr - the attribute to compare
|
1303
|
+
|
1304
|
+
[String] value - the value of the attribute that the element must include
|
1305
|
+
|
1306
|
+
__Returns:__
|
1307
|
+
|
1308
|
+
[Element] the element of type tag who's attribute includes value
|
1305
1309
|
|
1306
1310
|
--
|
1307
1311
|
|
1308
|
-
##### [
|
1312
|
+
##### [find_eles_by_attr_include](https://github.com/appium/ruby_lib/blob/5a3ecbb4147693ce3c2c6b693e64074022d03511/lib/appium_lib/android/helper.rb#L166) android
|
1309
1313
|
|
1310
|
-
> def
|
1314
|
+
> def find_eles_by_attr_include class_name, attr, value
|
1311
1315
|
|
1312
|
-
|
1316
|
+
Find elements by attribute that include value.
|
1317
|
+
|
1318
|
+
__Parameters:__
|
1319
|
+
|
1320
|
+
[String] class_name - the tag name to match
|
1321
|
+
|
1322
|
+
[String] attr - the attribute to compare
|
1323
|
+
|
1324
|
+
[String] value - the value of the attribute that the element must include
|
1325
|
+
|
1326
|
+
__Returns:__
|
1327
|
+
|
1328
|
+
[Array<Element>] the elements of type tag who's attribute includes value
|
1313
1329
|
|
1314
1330
|
--
|
1315
1331
|
|
1316
|
-
##### [
|
1332
|
+
##### [first_ele](https://github.com/appium/ruby_lib/blob/5a3ecbb4147693ce3c2c6b693e64074022d03511/lib/appium_lib/android/helper.rb#L173) android
|
1333
|
+
|
1334
|
+
> def first_ele class_name
|
1335
|
+
|
1336
|
+
Find the first element that matches class_name
|
1317
1337
|
|
1318
|
-
|
1338
|
+
__Parameters:__
|
1339
|
+
|
1340
|
+
[String] class_name - the tag to match
|
1319
1341
|
|
1320
|
-
|
1342
|
+
__Returns:__
|
1343
|
+
|
1344
|
+
[Element]
|
1321
1345
|
|
1322
1346
|
--
|
1323
1347
|
|
1324
|
-
##### [
|
1348
|
+
##### [last_ele](https://github.com/appium/ruby_lib/blob/5a3ecbb4147693ce3c2c6b693e64074022d03511/lib/appium_lib/android/helper.rb#L181) android
|
1349
|
+
|
1350
|
+
> def last_ele class_name
|
1325
1351
|
|
1326
|
-
|
1352
|
+
Find the last element that matches class_name
|
1327
1353
|
|
1328
|
-
|
1354
|
+
__Parameters:__
|
1355
|
+
|
1356
|
+
[String] class_name - the tag to match
|
1357
|
+
|
1358
|
+
__Returns:__
|
1359
|
+
|
1360
|
+
[Element]
|
1329
1361
|
|
1330
1362
|
--
|
1331
1363
|
|
1332
|
-
##### [
|
1364
|
+
##### [tag](https://github.com/appium/ruby_lib/blob/5a3ecbb4147693ce3c2c6b693e64074022d03511/lib/appium_lib/android/helper.rb#L189) android
|
1365
|
+
|
1366
|
+
> def tag class_name
|
1333
1367
|
|
1334
|
-
|
1368
|
+
Find the first element of type class_name
|
1335
1369
|
|
1336
|
-
|
1370
|
+
__Parameters:__
|
1371
|
+
|
1372
|
+
[String] class_name - the class_name to search for
|
1373
|
+
|
1374
|
+
__Returns:__
|
1375
|
+
|
1376
|
+
[Element]
|
1337
1377
|
|
1338
1378
|
--
|
1339
1379
|
|
1340
|
-
##### [
|
1380
|
+
##### [tags](https://github.com/appium/ruby_lib/blob/5a3ecbb4147693ce3c2c6b693e64074022d03511/lib/appium_lib/android/helper.rb#L197) android
|
1381
|
+
|
1382
|
+
> def tags class_name
|
1341
1383
|
|
1342
|
-
|
1384
|
+
Find all elements of type class_name
|
1343
1385
|
|
1344
|
-
|
1386
|
+
__Parameters:__
|
1387
|
+
|
1388
|
+
[String] class_name - the class_name to search for
|
1389
|
+
|
1390
|
+
__Returns:__
|
1391
|
+
|
1392
|
+
[Element]
|
1345
1393
|
|
1346
1394
|
--
|
1347
1395
|
|
1348
|
-
##### [
|
1396
|
+
##### [xpath_visible_contains](https://github.com/appium/ruby_lib/blob/5a3ecbb4147693ce3c2c6b693e64074022d03511/lib/appium_lib/android/helper.rb#L232) android
|
1349
1397
|
|
1350
|
-
> def
|
1398
|
+
> def xpath_visible_contains element, value
|
1351
1399
|
|
1352
|
-
|
1400
|
+
Find the first element that contains value
|
1401
|
+
|
1402
|
+
__Parameters:__
|
1403
|
+
|
1404
|
+
[String] element - the class name for the element
|
1405
|
+
|
1406
|
+
[String] value - the value to search for
|
1407
|
+
|
1408
|
+
__Returns:__
|
1409
|
+
|
1410
|
+
[Element]
|
1353
1411
|
|
1354
1412
|
--
|
1355
1413
|
|
1356
|
-
##### [
|
1414
|
+
##### [xpaths_visible_contains](https://github.com/appium/ruby_lib/blob/5a3ecbb4147693ce3c2c6b693e64074022d03511/lib/appium_lib/android/helper.rb#L240) android
|
1357
1415
|
|
1358
|
-
> def
|
1416
|
+
> def xpaths_visible_contains element, value
|
1359
1417
|
|
1360
|
-
|
1418
|
+
Find all elements containing value
|
1419
|
+
|
1420
|
+
__Parameters:__
|
1421
|
+
|
1422
|
+
[String] element - the class name for the element
|
1423
|
+
|
1424
|
+
[String] value - the value to search for
|
1425
|
+
|
1426
|
+
__Returns:__
|
1427
|
+
|
1428
|
+
[Array<Element>]
|
1361
1429
|
|
1362
1430
|
--
|
1363
1431
|
|
1364
|
-
##### [
|
1432
|
+
##### [xpath_visible_exact](https://github.com/appium/ruby_lib/blob/5a3ecbb4147693ce3c2c6b693e64074022d03511/lib/appium_lib/android/helper.rb#L266) android
|
1365
1433
|
|
1366
|
-
> def
|
1434
|
+
> def xpath_visible_exact element, value
|
1367
1435
|
|
1368
|
-
|
1369
|
-
:device is :android, :ios, or :selendroid
|
1436
|
+
Find the first element exactly matching value
|
1370
1437
|
|
1371
|
-
|
1372
|
-
# Options include:
|
1373
|
-
:app_path, :app_name, :app_package, :app_activity,
|
1374
|
-
:app_wait_activity, :sauce_username, :sauce_access_key,
|
1375
|
-
:port, :os, :debug
|
1438
|
+
__Parameters:__
|
1376
1439
|
|
1377
|
-
|
1378
|
-
require 'appium_lib'
|
1440
|
+
[String] element - the class name for the element
|
1379
1441
|
|
1380
|
-
|
1381
|
-
app = { device: :ios, app_path: '/path/to/MyiOS.app'}
|
1382
|
-
Appium::Driver.new(app).start_driver
|
1442
|
+
[String] value - the value to search for
|
1383
1443
|
|
1384
|
-
|
1385
|
-
apk = { device: :android
|
1386
|
-
app_path: '/path/to/the.apk',
|
1387
|
-
app_package: 'com.example.pkg',
|
1388
|
-
app_activity: 'act.Start',
|
1389
|
-
app_wait_activity: 'act.Start'
|
1390
|
-
}
|
1444
|
+
__Returns:__
|
1391
1445
|
|
1392
|
-
|
1393
|
-
|
1446
|
+
[Element]
|
1447
|
+
|
1448
|
+
--
|
1449
|
+
|
1450
|
+
##### [xpaths_visible_exact](https://github.com/appium/ruby_lib/blob/5a3ecbb4147693ce3c2c6b693e64074022d03511/lib/appium_lib/android/helper.rb#L274) android
|
1451
|
+
|
1452
|
+
> def xpaths_visible_exact element, value
|
1453
|
+
|
1454
|
+
Find all elements exactly matching value
|
1394
1455
|
|
1395
1456
|
__Parameters:__
|
1396
1457
|
|
1397
|
-
[
|
1458
|
+
[String] element - the class name for the element
|
1459
|
+
|
1460
|
+
[String] value - the value to search for
|
1398
1461
|
|
1399
1462
|
__Returns:__
|
1400
1463
|
|
1401
|
-
[
|
1464
|
+
[Element]
|
1402
1465
|
|
1403
1466
|
--
|
1404
1467
|
|
1405
|
-
##### [
|
1468
|
+
##### [TextView](https://github.com/appium/ruby_lib/blob/5a3ecbb4147693ce3c2c6b693e64074022d03511/lib/appium_lib/android/element/text.rb#L4) android
|
1406
1469
|
|
1407
|
-
>
|
1470
|
+
> TextView = 'android.widget.TextView'
|
1408
1471
|
|
1409
|
-
Returns the status payload
|
1410
1472
|
|
1411
|
-
```ruby
|
1412
|
-
{"status"=>0,
|
1413
|
-
"value"=>
|
1414
|
-
{"build"=>
|
1415
|
-
{"version"=>"0.8.2",
|
1416
|
-
"revision"=>"f2a2bc3782e4b0370d97a097d7e04913cf008995"}},
|
1417
|
-
"sessionId"=>"8f4b34a7-a9a9-4ac5-b125-36258143446a"}
|
1418
|
-
```
|
1419
1473
|
|
1420
|
-
|
1474
|
+
--
|
1475
|
+
|
1476
|
+
##### [s_text](https://github.com/appium/ruby_lib/blob/5a3ecbb4147693ce3c2c6b693e64074022d03511/lib/appium_lib/android/element/text.rb#L10) android
|
1421
1477
|
|
1422
|
-
|
1423
|
-
|
1478
|
+
> def s_text value
|
1479
|
+
|
1480
|
+
Find the first TextView that contains value or by index.
|
1481
|
+
If int then the TextView at that index is returned.
|
1482
|
+
|
1483
|
+
__Parameters:__
|
1484
|
+
|
1485
|
+
[String, Integer] value - the value to find.
|
1424
1486
|
|
1425
1487
|
__Returns:__
|
1426
1488
|
|
1427
|
-
[
|
1489
|
+
[TextView]
|
1428
1490
|
|
1429
1491
|
--
|
1430
1492
|
|
1431
|
-
##### [
|
1493
|
+
##### [s_texts](https://github.com/appium/ruby_lib/blob/5a3ecbb4147693ce3c2c6b693e64074022d03511/lib/appium_lib/android/element/text.rb#L18) android
|
1494
|
+
|
1495
|
+
> def s_texts value
|
1496
|
+
|
1497
|
+
Find all TextViews containing value.
|
1432
1498
|
|
1433
|
-
|
1499
|
+
__Parameters:__
|
1434
1500
|
|
1435
|
-
|
1501
|
+
[String] value - the value to search for
|
1436
1502
|
|
1437
1503
|
__Returns:__
|
1438
1504
|
|
1439
|
-
[
|
1505
|
+
[Array<TextView>]
|
1440
1506
|
|
1441
1507
|
--
|
1442
1508
|
|
1443
|
-
##### [
|
1509
|
+
##### [first_s_text](https://github.com/appium/ruby_lib/blob/5a3ecbb4147693ce3c2c6b693e64074022d03511/lib/appium_lib/android/element/text.rb#L24) android
|
1444
1510
|
|
1445
|
-
> def
|
1511
|
+
> def first_s_text
|
1446
1512
|
|
1447
|
-
|
1513
|
+
Find the first TextView.
|
1448
1514
|
|
1449
1515
|
__Returns:__
|
1450
1516
|
|
1451
|
-
[
|
1517
|
+
[TextView]
|
1452
1518
|
|
1453
1519
|
--
|
1454
1520
|
|
1455
|
-
##### [
|
1521
|
+
##### [last_s_text](https://github.com/appium/ruby_lib/blob/5a3ecbb4147693ce3c2c6b693e64074022d03511/lib/appium_lib/android/element/text.rb#L30) android
|
1456
1522
|
|
1457
|
-
> def
|
1523
|
+
> def last_s_text
|
1458
1524
|
|
1459
|
-
|
1525
|
+
Find the last TextView.
|
1460
1526
|
|
1461
1527
|
__Returns:__
|
1462
1528
|
|
1463
|
-
[
|
1529
|
+
[TextView]
|
1464
1530
|
|
1465
1531
|
--
|
1466
1532
|
|
1467
|
-
##### [
|
1533
|
+
##### [s_text_exact](https://github.com/appium/ruby_lib/blob/5a3ecbb4147693ce3c2c6b693e64074022d03511/lib/appium_lib/android/element/text.rb#L37) android
|
1468
1534
|
|
1469
|
-
> def
|
1535
|
+
> def s_text_exact value
|
1470
1536
|
|
1471
|
-
|
1537
|
+
Find the first TextView that exactly matches value.
|
1538
|
+
|
1539
|
+
__Parameters:__
|
1540
|
+
|
1541
|
+
[String] value - the value to match exactly
|
1472
1542
|
|
1473
1543
|
__Returns:__
|
1474
1544
|
|
1475
|
-
[
|
1545
|
+
[TextView]
|
1476
1546
|
|
1477
1547
|
--
|
1478
1548
|
|
1479
|
-
##### [
|
1549
|
+
##### [s_texts_exact](https://github.com/appium/ruby_lib/blob/5a3ecbb4147693ce3c2c6b693e64074022d03511/lib/appium_lib/android/element/text.rb#L44) android
|
1480
1550
|
|
1481
|
-
> def
|
1551
|
+
> def s_texts_exact value
|
1482
1552
|
|
1483
|
-
|
1553
|
+
Find all TextViews that exactly match value.
|
1554
|
+
|
1555
|
+
__Parameters:__
|
1556
|
+
|
1557
|
+
[String] value - the value to match exactly
|
1484
1558
|
|
1485
1559
|
__Returns:__
|
1486
1560
|
|
1487
|
-
[
|
1561
|
+
[Array<TextView>]
|
1488
1562
|
|
1489
1563
|
--
|
1490
1564
|
|
1491
|
-
##### [
|
1565
|
+
##### [e_s_texts](https://github.com/appium/ruby_lib/blob/5a3ecbb4147693ce3c2c6b693e64074022d03511/lib/appium_lib/android/element/text.rb#L50) android
|
1492
1566
|
|
1493
|
-
> def
|
1567
|
+
> def e_s_texts
|
1494
1568
|
|
1495
|
-
|
1569
|
+
Find all TextViews.
|
1496
1570
|
|
1497
|
-
|
1571
|
+
__Returns:__
|
1572
|
+
|
1573
|
+
[Array<TextView>]
|
1574
|
+
|
1575
|
+
--
|
1576
|
+
|
1577
|
+
##### [alert_click](https://github.com/appium/ruby_lib/blob/5a3ecbb4147693ce3c2c6b693e64074022d03511/lib/appium_lib/android/element/alert.rb#L6) android
|
1578
|
+
|
1579
|
+
> def alert_click value
|
1580
|
+
|
1581
|
+
Click the first alert button that contains value or by index.
|
1498
1582
|
|
1499
1583
|
__Parameters:__
|
1500
1584
|
|
1501
|
-
[String]
|
1585
|
+
[Integer, String] value - either an integer index of the button or the button's name
|
1502
1586
|
|
1503
1587
|
__Returns:__
|
1504
1588
|
|
1505
|
-
[
|
1589
|
+
[void]
|
1506
1590
|
|
1507
1591
|
--
|
1508
1592
|
|
1509
|
-
##### [
|
1593
|
+
##### [alert_accept](https://github.com/appium/ruby_lib/blob/5a3ecbb4147693ce3c2c6b693e64074022d03511/lib/appium_lib/android/element/alert.rb#L13) android
|
1510
1594
|
|
1511
|
-
> def
|
1595
|
+
> def alert_accept
|
1512
1596
|
|
1513
|
-
|
1597
|
+
Accept the alert.
|
1598
|
+
The last button is considered "accept."
|
1514
1599
|
|
1515
1600
|
__Returns:__
|
1516
1601
|
|
@@ -1518,163 +1603,414 @@ __Returns:__
|
|
1518
1603
|
|
1519
1604
|
--
|
1520
1605
|
|
1521
|
-
##### [
|
1606
|
+
##### [alert_accept_text](https://github.com/appium/ruby_lib/blob/5a3ecbb4147693ce3c2c6b693e64074022d03511/lib/appium_lib/android/element/alert.rb#L20) android
|
1522
1607
|
|
1523
|
-
> def
|
1608
|
+
> def alert_accept_text
|
1524
1609
|
|
1525
|
-
|
1610
|
+
Get the text of the alert's accept button.
|
1611
|
+
The last button is considered "accept."
|
1526
1612
|
|
1527
1613
|
__Returns:__
|
1528
1614
|
|
1529
|
-
[
|
1615
|
+
[String]
|
1530
1616
|
|
1531
1617
|
--
|
1532
1618
|
|
1533
|
-
##### [
|
1619
|
+
##### [alert_dismiss](https://github.com/appium/ruby_lib/blob/5a3ecbb4147693ce3c2c6b693e64074022d03511/lib/appium_lib/android/element/alert.rb#L27) android
|
1534
1620
|
|
1535
|
-
> def
|
1621
|
+
> def alert_dismiss
|
1536
1622
|
|
1537
|
-
|
1623
|
+
Dismiss the alert.
|
1624
|
+
The first button is considered "dismiss."
|
1625
|
+
|
1626
|
+
__Returns:__
|
1627
|
+
|
1628
|
+
[void]
|
1538
1629
|
|
1539
1630
|
--
|
1540
1631
|
|
1541
|
-
##### [
|
1632
|
+
##### [alert_dismiss_text](https://github.com/appium/ruby_lib/blob/5a3ecbb4147693ce3c2c6b693e64074022d03511/lib/appium_lib/android/element/alert.rb#L34) android
|
1542
1633
|
|
1543
|
-
> def
|
1634
|
+
> def alert_dismiss_text
|
1544
1635
|
|
1545
|
-
|
1546
|
-
|
1547
|
-
wait will be used.
|
1636
|
+
Get the text of the alert's dismiss button.
|
1637
|
+
The first button is considered "dismiss."
|
1548
1638
|
|
1549
|
-
|
1550
|
-
set_wait 2
|
1551
|
-
set_wait 3
|
1552
|
-
set_wait # 2
|
1639
|
+
__Returns:__
|
1553
1640
|
|
1554
|
-
|
1641
|
+
[String]
|
1642
|
+
|
1643
|
+
--
|
1644
|
+
|
1645
|
+
##### [uiautomator_find](https://github.com/appium/ruby_lib/blob/5a3ecbb4147693ce3c2c6b693e64074022d03511/lib/appium_lib/android/mobile_methods.rb#L10) android
|
1646
|
+
|
1647
|
+
> def uiautomator_find
|
1648
|
+
|
1649
|
+
find_element/s can be used with a [UISelector](http://developer.android.com/tools/help/uiautomator/UiSelector.html).
|
1650
|
+
|
1651
|
+
```ruby
|
1652
|
+
find_elements :uiautomator, 'new UiSelector().clickable(true)'
|
1653
|
+
```
|
1654
|
+
|
1655
|
+
--
|
1656
|
+
|
1657
|
+
##### [Button](https://github.com/appium/ruby_lib/blob/5a3ecbb4147693ce3c2c6b693e64074022d03511/lib/appium_lib/android/element/button.rb#L4) android
|
1658
|
+
|
1659
|
+
> Button = 'android.widget.Button'
|
1660
|
+
|
1661
|
+
|
1662
|
+
|
1663
|
+
--
|
1664
|
+
|
1665
|
+
##### [ImageButton](https://github.com/appium/ruby_lib/blob/5a3ecbb4147693ce3c2c6b693e64074022d03511/lib/appium_lib/android/element/button.rb#L5) android
|
1666
|
+
|
1667
|
+
> ImageButton = 'android.widget.ImageButton'
|
1668
|
+
|
1669
|
+
|
1670
|
+
|
1671
|
+
--
|
1672
|
+
|
1673
|
+
##### [button](https://github.com/appium/ruby_lib/blob/5a3ecbb4147693ce3c2c6b693e64074022d03511/lib/appium_lib/android/element/button.rb#L39) android
|
1674
|
+
|
1675
|
+
> def button value
|
1676
|
+
|
1677
|
+
Find the first button that contains value or by index.
|
1678
|
+
If int then the button at that index is returned.
|
1555
1679
|
|
1556
1680
|
__Parameters:__
|
1557
1681
|
|
1558
|
-
[Integer]
|
1682
|
+
[String, Integer] value - the value to exactly match.
|
1559
1683
|
|
1560
1684
|
__Returns:__
|
1561
1685
|
|
1562
|
-
[
|
1686
|
+
[Button]
|
1563
1687
|
|
1564
1688
|
--
|
1565
1689
|
|
1566
|
-
##### [
|
1690
|
+
##### [buttons](https://github.com/appium/ruby_lib/blob/5a3ecbb4147693ce3c2c6b693e64074022d03511/lib/appium_lib/android/element/button.rb#L55) android
|
1567
1691
|
|
1568
|
-
> def
|
1692
|
+
> def buttons value
|
1569
1693
|
|
1570
|
-
|
1694
|
+
Find all buttons containing value
|
1571
1695
|
|
1572
|
-
|
1696
|
+
__Parameters:__
|
1573
1697
|
|
1574
|
-
|
1698
|
+
[String] value - the value to search for
|
1699
|
+
|
1700
|
+
__Returns:__
|
1701
|
+
|
1702
|
+
[Array<Button>]
|
1703
|
+
|
1704
|
+
--
|
1705
|
+
|
1706
|
+
##### [first_button](https://github.com/appium/ruby_lib/blob/5a3ecbb4147693ce3c2c6b693e64074022d03511/lib/appium_lib/android/element/button.rb#L61) android
|
1707
|
+
|
1708
|
+
> def first_button
|
1709
|
+
|
1710
|
+
Find the first button.
|
1711
|
+
|
1712
|
+
__Returns:__
|
1713
|
+
|
1714
|
+
[Button]
|
1715
|
+
|
1716
|
+
--
|
1717
|
+
|
1718
|
+
##### [last_button](https://github.com/appium/ruby_lib/blob/5a3ecbb4147693ce3c2c6b693e64074022d03511/lib/appium_lib/android/element/button.rb#L67) android
|
1719
|
+
|
1720
|
+
> def last_button
|
1721
|
+
|
1722
|
+
Find the last button.
|
1723
|
+
|
1724
|
+
__Returns:__
|
1725
|
+
|
1726
|
+
[Button]
|
1727
|
+
|
1728
|
+
--
|
1729
|
+
|
1730
|
+
##### [button_exact](https://github.com/appium/ruby_lib/blob/5a3ecbb4147693ce3c2c6b693e64074022d03511/lib/appium_lib/android/element/button.rb#L74) android
|
1731
|
+
|
1732
|
+
> def button_exact value
|
1733
|
+
|
1734
|
+
Find the first button that exactly matches value.
|
1575
1735
|
|
1576
1736
|
__Parameters:__
|
1577
1737
|
|
1578
|
-
[
|
1579
|
-
wait to before checking existance
|
1738
|
+
[String] value - the value to match exactly
|
1580
1739
|
|
1581
|
-
|
1582
|
-
wait to after checking existance
|
1740
|
+
__Returns:__
|
1583
1741
|
|
1584
|
-
[
|
1742
|
+
[Button]
|
1743
|
+
|
1744
|
+
--
|
1745
|
+
|
1746
|
+
##### [buttons_exact](https://github.com/appium/ruby_lib/blob/5a3ecbb4147693ce3c2c6b693e64074022d03511/lib/appium_lib/android/element/button.rb#L81) android
|
1747
|
+
|
1748
|
+
> def buttons_exact value
|
1749
|
+
|
1750
|
+
Find all buttons that exactly match value.
|
1751
|
+
|
1752
|
+
__Parameters:__
|
1753
|
+
|
1754
|
+
[String] value - the value to match exactly
|
1585
1755
|
|
1586
1756
|
__Returns:__
|
1587
1757
|
|
1588
|
-
[
|
1758
|
+
[Array<Button>]
|
1589
1759
|
|
1590
1760
|
--
|
1591
1761
|
|
1592
|
-
##### [
|
1762
|
+
##### [e_buttons](https://github.com/appium/ruby_lib/blob/5a3ecbb4147693ce3c2c6b693e64074022d03511/lib/appium_lib/android/element/button.rb#L87) android
|
1593
1763
|
|
1594
|
-
> def
|
1764
|
+
> def e_buttons
|
1595
1765
|
|
1596
|
-
|
1766
|
+
Find all buttons.
|
1767
|
+
|
1768
|
+
__Returns:__
|
1769
|
+
|
1770
|
+
[Array<Button>]
|
1771
|
+
|
1772
|
+
--
|
1773
|
+
|
1774
|
+
##### [find](https://github.com/appium/ruby_lib/blob/5a3ecbb4147693ce3c2c6b693e64074022d03511/lib/appium_lib/android/element/generic.rb#L7) android
|
1775
|
+
|
1776
|
+
> def find value
|
1777
|
+
|
1778
|
+
Find the first element containing value
|
1597
1779
|
|
1598
1780
|
__Parameters:__
|
1599
1781
|
|
1600
|
-
[String]
|
1782
|
+
[String] value - the value to search for
|
1601
1783
|
|
1602
|
-
|
1784
|
+
__Returns:__
|
1785
|
+
|
1786
|
+
[Element]
|
1787
|
+
|
1788
|
+
--
|
1789
|
+
|
1790
|
+
##### [finds](https://github.com/appium/ruby_lib/blob/5a3ecbb4147693ce3c2c6b693e64074022d03511/lib/appium_lib/android/element/generic.rb#L14) android
|
1791
|
+
|
1792
|
+
> def finds value
|
1793
|
+
|
1794
|
+
Find all elements containing value
|
1795
|
+
|
1796
|
+
__Parameters:__
|
1797
|
+
|
1798
|
+
[String] value - the value to search for
|
1603
1799
|
|
1604
1800
|
__Returns:__
|
1605
1801
|
|
1606
|
-
[
|
1802
|
+
[Array<Element>]
|
1607
1803
|
|
1608
1804
|
--
|
1609
1805
|
|
1610
|
-
##### [
|
1806
|
+
##### [find_exact](https://github.com/appium/ruby_lib/blob/5a3ecbb4147693ce3c2c6b693e64074022d03511/lib/appium_lib/android/element/generic.rb#L21) android
|
1611
1807
|
|
1612
|
-
> def
|
1808
|
+
> def find_exact value
|
1613
1809
|
|
1614
|
-
|
1810
|
+
Find the first element exactly matching value
|
1615
1811
|
|
1616
|
-
|
1812
|
+
__Parameters:__
|
1617
1813
|
|
1618
|
-
|
1814
|
+
[String] value - the value to search for
|
1619
1815
|
|
1620
|
-
|
1816
|
+
__Returns:__
|
1621
1817
|
|
1622
|
-
|
1818
|
+
[Element]
|
1819
|
+
|
1820
|
+
--
|
1821
|
+
|
1822
|
+
##### [finds_exact](https://github.com/appium/ruby_lib/blob/5a3ecbb4147693ce3c2c6b693e64074022d03511/lib/appium_lib/android/element/generic.rb#L28) android
|
1823
|
+
|
1824
|
+
> def finds_exact value
|
1825
|
+
|
1826
|
+
Find all elements exactly matching value
|
1623
1827
|
|
1624
1828
|
__Parameters:__
|
1625
1829
|
|
1626
|
-
[String
|
1830
|
+
[String] value - the value to search for
|
1831
|
+
|
1832
|
+
__Returns:__
|
1627
1833
|
|
1628
|
-
[
|
1834
|
+
[Array<Element>]
|
1835
|
+
|
1836
|
+
--
|
1837
|
+
|
1838
|
+
##### [scroll_to](https://github.com/appium/ruby_lib/blob/5a3ecbb4147693ce3c2c6b693e64074022d03511/lib/appium_lib/android/element/generic.rb#L35) android
|
1839
|
+
|
1840
|
+
> def scroll_to text
|
1841
|
+
|
1842
|
+
Scroll to the first element containing target text or description.
|
1843
|
+
|
1844
|
+
__Parameters:__
|
1845
|
+
|
1846
|
+
[String] text - the text to search for in the text value and content description
|
1629
1847
|
|
1630
1848
|
__Returns:__
|
1631
1849
|
|
1632
|
-
[
|
1850
|
+
[Element] the element scrolled to
|
1633
1851
|
|
1634
1852
|
--
|
1635
1853
|
|
1636
|
-
##### [
|
1854
|
+
##### [scroll_to_exact](https://github.com/appium/ruby_lib/blob/5a3ecbb4147693ce3c2c6b693e64074022d03511/lib/appium_lib/android/element/generic.rb#L48) android
|
1637
1855
|
|
1638
|
-
> def
|
1856
|
+
> def scroll_to_exact text
|
1639
1857
|
|
1640
|
-
|
1858
|
+
Scroll to the first element with the exact target text or description.
|
1641
1859
|
|
1642
1860
|
__Parameters:__
|
1643
1861
|
|
1644
|
-
[
|
1862
|
+
[String] text - the text to search for in the text value and content description
|
1645
1863
|
|
1646
1864
|
__Returns:__
|
1647
1865
|
|
1648
|
-
[
|
1866
|
+
[Element] the element scrolled to
|
1649
1867
|
|
1650
1868
|
--
|
1651
1869
|
|
1652
|
-
##### [
|
1870
|
+
##### [EditText](https://github.com/appium/ruby_lib/blob/5a3ecbb4147693ce3c2c6b693e64074022d03511/lib/appium_lib/android/element/textfield.rb#L3) android
|
1653
1871
|
|
1654
|
-
>
|
1872
|
+
> EditText = 'android.widget.EditText'
|
1655
1873
|
|
1656
|
-
|
1874
|
+
|
1875
|
+
|
1876
|
+
--
|
1877
|
+
|
1878
|
+
##### [textfield](https://github.com/appium/ruby_lib/blob/5a3ecbb4147693ce3c2c6b693e64074022d03511/lib/appium_lib/android/element/textfield.rb#L9) android
|
1879
|
+
|
1880
|
+
> def textfield value
|
1881
|
+
|
1882
|
+
Find the first EditText that contains value or by index.
|
1883
|
+
If int then the EditText at that index is returned.
|
1657
1884
|
|
1658
1885
|
__Parameters:__
|
1659
1886
|
|
1660
|
-
[
|
1887
|
+
[String, Integer] value - the text to match exactly.
|
1661
1888
|
|
1662
1889
|
__Returns:__
|
1663
1890
|
|
1664
|
-
[
|
1891
|
+
[EditText]
|
1665
1892
|
|
1666
1893
|
--
|
1667
1894
|
|
1668
|
-
##### [
|
1895
|
+
##### [textfields](https://github.com/appium/ruby_lib/blob/5a3ecbb4147693ce3c2c6b693e64074022d03511/lib/appium_lib/android/element/textfield.rb#L17) android
|
1669
1896
|
|
1670
|
-
> def
|
1897
|
+
> def textfields value
|
1671
1898
|
|
1672
|
-
|
1673
|
-
|
1899
|
+
Find all EditTexts containing value.
|
1900
|
+
|
1901
|
+
__Parameters:__
|
1902
|
+
|
1903
|
+
[String] value - the value to search for
|
1674
1904
|
|
1675
1905
|
__Returns:__
|
1676
1906
|
|
1677
|
-
[
|
1907
|
+
[Array<EditText>]
|
1908
|
+
|
1909
|
+
--
|
1910
|
+
|
1911
|
+
##### [first_textfield](https://github.com/appium/ruby_lib/blob/5a3ecbb4147693ce3c2c6b693e64074022d03511/lib/appium_lib/android/element/textfield.rb#L23) android
|
1912
|
+
|
1913
|
+
> def first_textfield
|
1914
|
+
|
1915
|
+
Find the first EditText.
|
1916
|
+
|
1917
|
+
__Returns:__
|
1918
|
+
|
1919
|
+
[EditText]
|
1920
|
+
|
1921
|
+
--
|
1922
|
+
|
1923
|
+
##### [last_textfield](https://github.com/appium/ruby_lib/blob/5a3ecbb4147693ce3c2c6b693e64074022d03511/lib/appium_lib/android/element/textfield.rb#L29) android
|
1924
|
+
|
1925
|
+
> def last_textfield
|
1926
|
+
|
1927
|
+
Find the last EditText.
|
1928
|
+
|
1929
|
+
__Returns:__
|
1930
|
+
|
1931
|
+
[EditText]
|
1932
|
+
|
1933
|
+
--
|
1934
|
+
|
1935
|
+
##### [textfield_exact](https://github.com/appium/ruby_lib/blob/5a3ecbb4147693ce3c2c6b693e64074022d03511/lib/appium_lib/android/element/textfield.rb#L36) android
|
1936
|
+
|
1937
|
+
> def textfield_exact value
|
1938
|
+
|
1939
|
+
Find the first EditText that exactly matches value.
|
1940
|
+
|
1941
|
+
__Parameters:__
|
1942
|
+
|
1943
|
+
[String] value - the value to match exactly
|
1944
|
+
|
1945
|
+
__Returns:__
|
1946
|
+
|
1947
|
+
[EditText]
|
1948
|
+
|
1949
|
+
--
|
1950
|
+
|
1951
|
+
##### [textfields_exact](https://github.com/appium/ruby_lib/blob/5a3ecbb4147693ce3c2c6b693e64074022d03511/lib/appium_lib/android/element/textfield.rb#L43) android
|
1952
|
+
|
1953
|
+
> def textfields_exact value
|
1954
|
+
|
1955
|
+
Find all EditTexts that exactly match value.
|
1956
|
+
|
1957
|
+
__Parameters:__
|
1958
|
+
|
1959
|
+
[String] value - the value to match exactly
|
1960
|
+
|
1961
|
+
__Returns:__
|
1962
|
+
|
1963
|
+
[Array<EditText>]
|
1964
|
+
|
1965
|
+
--
|
1966
|
+
|
1967
|
+
##### [e_textfields](https://github.com/appium/ruby_lib/blob/5a3ecbb4147693ce3c2c6b693e64074022d03511/lib/appium_lib/android/element/textfield.rb#L49) android
|
1968
|
+
|
1969
|
+
> def e_textfields
|
1970
|
+
|
1971
|
+
Find all EditTexts.
|
1972
|
+
|
1973
|
+
__Returns:__
|
1974
|
+
|
1975
|
+
[Array<EditText>]
|
1976
|
+
|
1977
|
+
--
|
1978
|
+
|
1979
|
+
##### [value](https://github.com/appium/ruby_lib/blob/5a3ecbb4147693ce3c2c6b693e64074022d03511/lib/appium_lib/common/patch.rb#L10)
|
1980
|
+
|
1981
|
+
> def value
|
1982
|
+
|
1983
|
+
Returns the value attribute
|
1984
|
+
|
1985
|
+
Fixes NoMethodError: undefined method `value' for Selenium::WebDriver::Element
|
1986
|
+
|
1987
|
+
--
|
1988
|
+
|
1989
|
+
##### [name](https://github.com/appium/ruby_lib/blob/5a3ecbb4147693ce3c2c6b693e64074022d03511/lib/appium_lib/common/patch.rb#L17)
|
1990
|
+
|
1991
|
+
> def name
|
1992
|
+
|
1993
|
+
Returns the name attribute
|
1994
|
+
|
1995
|
+
Fixes NoMethodError: undefined method `name' for Selenium::WebDriver::Element
|
1996
|
+
|
1997
|
+
--
|
1998
|
+
|
1999
|
+
##### [location_rel](https://github.com/appium/ruby_lib/blob/5a3ecbb4147693ce3c2c6b693e64074022d03511/lib/appium_lib/common/patch.rb#L29)
|
2000
|
+
|
2001
|
+
> def location_rel
|
2002
|
+
|
2003
|
+
For use with mobile tap.
|
2004
|
+
|
2005
|
+
```ruby
|
2006
|
+
execute_script 'mobile: tap', :x => 0.0, :y => 0.98
|
2007
|
+
```
|
2008
|
+
|
2009
|
+
https://github.com/appium/appium/wiki/Automating-mobile-gestures
|
2010
|
+
|
2011
|
+
__Returns:__
|
2012
|
+
|
2013
|
+
[OpenStruct] the relative x, y in a struct. ex: { x: 0.50, y: 0.20 }
|
1678
2014
|
|
1679
2015
|
--
|
1680
2016
|
|