appium_lib 9.7.5 → 9.8.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +25 -0
- data/appium_lib.gemspec +1 -3
- data/contributing.md +2 -0
- data/docs/android_docs.md +186 -180
- data/docs/ios_docs.md +238 -234
- data/docs/ios_xcuitest.md +1 -1
- data/lib/appium_lib/android/common/helper.rb +0 -30
- data/lib/appium_lib/appium.rb +3 -4
- data/lib/appium_lib/common/helper.rb +0 -1
- data/lib/appium_lib/common/http_client.rb +1 -1
- data/lib/appium_lib/common/touch_actions.rb +4 -4
- data/lib/appium_lib/common/wait.rb +1 -1
- data/lib/appium_lib/driver.rb +7 -8
- data/lib/appium_lib/ios/common/helper.rb +1 -8
- data/lib/appium_lib/version.rb +2 -2
- data/readme.md +29 -8
- data/release_notes.md +6 -0
- metadata +5 -77
- data/lib/appium_lib/core/android.rb +0 -5
- data/lib/appium_lib/core/android/device.rb +0 -142
- data/lib/appium_lib/core/android/espresso/bridge.rb +0 -18
- data/lib/appium_lib/core/android/search_context.rb +0 -17
- data/lib/appium_lib/core/android/touch.rb +0 -15
- data/lib/appium_lib/core/android/uiautomator1/bridge.rb +0 -18
- data/lib/appium_lib/core/android/uiautomator2/bridge.rb +0 -18
- data/lib/appium_lib/core/android_espresso.rb +0 -5
- data/lib/appium_lib/core/android_uiautomator2.rb +0 -5
- data/lib/appium_lib/core/common.rb +0 -6
- data/lib/appium_lib/core/common/base.rb +0 -8
- data/lib/appium_lib/core/common/base/bridge.rb +0 -47
- data/lib/appium_lib/core/common/base/capabilities.rb +0 -16
- data/lib/appium_lib/core/common/base/command.rb +0 -10
- data/lib/appium_lib/core/common/base/driver.rb +0 -40
- data/lib/appium_lib/core/common/base/http_default.rb +0 -12
- data/lib/appium_lib/core/common/base/search_context.rb +0 -89
- data/lib/appium_lib/core/common/base/wait.rb +0 -56
- data/lib/appium_lib/core/common/command.rb +0 -75
- data/lib/appium_lib/core/common/device.rb +0 -462
- data/lib/appium_lib/core/common/error.rb +0 -18
- data/lib/appium_lib/core/common/log.rb +0 -30
- data/lib/appium_lib/core/common/logger.rb +0 -35
- data/lib/appium_lib/core/core.rb +0 -67
- data/lib/appium_lib/core/device/multi_touch.rb +0 -48
- data/lib/appium_lib/core/device/touch_actions.rb +0 -191
- data/lib/appium_lib/core/driver.rb +0 -417
- data/lib/appium_lib/core/ios.rb +0 -7
- data/lib/appium_lib/core/ios/device.rb +0 -44
- data/lib/appium_lib/core/ios/search_context.rb +0 -27
- data/lib/appium_lib/core/ios/touch.rb +0 -16
- data/lib/appium_lib/core/ios/uiautomation/bridge.rb +0 -20
- data/lib/appium_lib/core/ios/uiautomation/patch.rb +0 -20
- data/lib/appium_lib/core/ios/xcuitest/bridge.rb +0 -20
- data/lib/appium_lib/core/ios/xcuitest/device.rb +0 -59
- data/lib/appium_lib/core/ios/xcuitest/search_context.rb +0 -40
- data/lib/appium_lib/core/ios_xcuitest.rb +0 -8
- data/lib/appium_lib/core/patch.rb +0 -56
data/docs/ios_xcuitest.md
CHANGED
@@ -82,7 +82,7 @@ xpaths("//some xpaths")
|
|
82
82
|
## Gesture
|
83
83
|
- `mobile:` commands are provided by WDA.
|
84
84
|
- Documentations
|
85
|
-
- https://github.com/appium/appium/blob/master/docs/en/writing-running-appium/ios-xctest-mobile-gestures.md
|
85
|
+
- https://github.com/appium/appium/blob/master/docs/en/writing-running-appium/ios/ios-xctest-mobile-gestures.md
|
86
86
|
- Specs by test code
|
87
87
|
- https://github.com/appium/appium-xcuitest-driver/blob/master/test/functional/basic/gesture-e2e-specs.js
|
88
88
|
|
@@ -109,36 +109,6 @@ module Appium
|
|
109
109
|
nil
|
110
110
|
end
|
111
111
|
|
112
|
-
# Lists package, activity, and adb shell am start -n value for current app.
|
113
|
-
# Works on local host only (not remote).
|
114
|
-
|
115
|
-
# example line:
|
116
|
-
# "mFocusedApp=AppWindowToken{b1420058 token=Token{b128add0
|
117
|
-
# ActivityRecord{b1264d10 u0 com.example.android.apis/.ApiDemos t23}}}"
|
118
|
-
def current_app
|
119
|
-
warn '[DEPRECATION] current_app will be removed since it work only local.' \
|
120
|
-
'Please use current_activity and current_app to know package and activity for current app'
|
121
|
-
|
122
|
-
line = `adb shell dumpsys window windows`.each_line.grep(/mFocusedApp/).first.strip
|
123
|
-
|
124
|
-
_parse_current_app_line line
|
125
|
-
end
|
126
|
-
|
127
|
-
# @private
|
128
|
-
# noinspection RubyArgCount
|
129
|
-
def _parse_current_app_line(line)
|
130
|
-
match = line.match(/ ([^\/ ]+\/[^ }]+)[ }]/)
|
131
|
-
return nil unless match && match[1]
|
132
|
-
|
133
|
-
pair = match[1].split '/'
|
134
|
-
pkg = pair.first
|
135
|
-
act = pair.last
|
136
|
-
OpenStruct.new(line: line,
|
137
|
-
package: pkg,
|
138
|
-
activity: act,
|
139
|
-
am_start: pkg + '/' + act)
|
140
|
-
end
|
141
|
-
|
142
112
|
# Find the first matching element by id
|
143
113
|
# @param id [String] the id to search for
|
144
114
|
# @return [Element]
|
data/lib/appium_lib/appium.rb
CHANGED
@@ -2,6 +2,8 @@ require 'rubygems'
|
|
2
2
|
require 'selenium-webdriver'
|
3
3
|
require 'nokogiri'
|
4
4
|
|
5
|
+
require 'appium_lib_core'
|
6
|
+
|
5
7
|
# base
|
6
8
|
require_relative 'driver'
|
7
9
|
require_relative 'sauce_labs'
|
@@ -15,9 +17,6 @@ require_relative 'common/touch_actions'
|
|
15
17
|
require_relative 'common/http_client'
|
16
18
|
require_relative 'common/device'
|
17
19
|
|
18
|
-
# core
|
19
|
-
require_relative 'core/core'
|
20
|
-
|
21
20
|
# ios
|
22
21
|
require_relative 'ios/ios'
|
23
22
|
|
@@ -62,7 +61,7 @@ module Appium
|
|
62
61
|
|
63
62
|
data = Tomlrb.load_file(toml, symbolize_keys: true)
|
64
63
|
if verbose
|
65
|
-
Appium::Logger.
|
64
|
+
Appium::Logger.info data unless data.empty?
|
66
65
|
end
|
67
66
|
|
68
67
|
if data && data[:caps] && data[:caps][:app] && !data[:caps][:app].empty?
|
@@ -24,10 +24,10 @@ module Appium
|
|
24
24
|
# @example
|
25
25
|
#
|
26
26
|
# driver = Appium::Driver.new(opts, false).start_driver
|
27
|
-
# action = TouchAction.new.press(x: 45, y: 100).wait(5).release
|
28
|
-
# action.perform
|
29
|
-
# action = TouchAction.new.swipe(....)
|
30
|
-
# action.perform
|
27
|
+
# action = TouchAction.new(driver).press(x: 45, y: 100).wait(5).release
|
28
|
+
# action.perform
|
29
|
+
# action = TouchAction.new(driver).swipe(....)
|
30
|
+
# action.perform
|
31
31
|
#
|
32
32
|
class TouchAction < ::Appium::Core::TouchAction
|
33
33
|
COMPLEX_ACTIONS = ::Appium::Core::TouchAction::COMPLEX_ACTIONS
|
data/lib/appium_lib/driver.rb
CHANGED
@@ -9,7 +9,7 @@ module Minitest
|
|
9
9
|
end
|
10
10
|
end
|
11
11
|
|
12
|
-
|
12
|
+
require 'appium_lib_core'
|
13
13
|
|
14
14
|
module Appium
|
15
15
|
REQUIRED_VERSION_XCUITEST = '1.6.0'.freeze
|
@@ -36,6 +36,7 @@ module Appium
|
|
36
36
|
attr_reader :sauce_endpoint
|
37
37
|
|
38
38
|
# from Core
|
39
|
+
# read http://www.rubydoc.info/github/appium/ruby_lib_core/Appium/Core/Driver
|
39
40
|
attr_reader :caps
|
40
41
|
attr_reader :custom_url
|
41
42
|
attr_reader :export_session
|
@@ -172,7 +173,7 @@ module Appium
|
|
172
173
|
# for command
|
173
174
|
|
174
175
|
if @appium_debug
|
175
|
-
Appium::Logger.
|
176
|
+
Appium::Logger.debug opts unless opts.empty?
|
176
177
|
Appium::Logger.debug "Debug is: #{@appium_debug}"
|
177
178
|
Appium::Logger.debug "Device is: #{@core.device}"
|
178
179
|
end
|
@@ -312,6 +313,7 @@ module Appium
|
|
312
313
|
# server (TestObject for instance) does not respond to status call
|
313
314
|
{}
|
314
315
|
end
|
316
|
+
alias remote_status appium_server_version
|
315
317
|
|
316
318
|
# Return the platform version as an array of integers
|
317
319
|
# @return [Array<Integer>]
|
@@ -319,12 +321,6 @@ module Appium
|
|
319
321
|
@core.platform_version
|
320
322
|
end
|
321
323
|
|
322
|
-
# @private
|
323
|
-
def ios_version
|
324
|
-
warn '[DEPRECATION] ios_version will be removed. Please use platform_version instead.'
|
325
|
-
platform_version
|
326
|
-
end
|
327
|
-
|
328
324
|
# Returns the client's version info
|
329
325
|
#
|
330
326
|
# @example
|
@@ -428,6 +424,9 @@ module Appium
|
|
428
424
|
# Creates a new global driver and quits the old one if it exists.
|
429
425
|
# You can customise http_client as the following
|
430
426
|
#
|
427
|
+
# Read http://www.rubydoc.info/github/appium/ruby_lib_core/Appium/Core/Device to understand more what the driver
|
428
|
+
# can call instance methods.
|
429
|
+
#
|
431
430
|
# @example
|
432
431
|
#
|
433
432
|
# require 'rubygems'
|
@@ -69,7 +69,7 @@ module Appium
|
|
69
69
|
parser.parse s
|
70
70
|
parser.document.result
|
71
71
|
else
|
72
|
-
s =
|
72
|
+
s = get_source
|
73
73
|
parser = Nokogiri::XML::SAX::Parser.new(UITestElementsPrinter.new)
|
74
74
|
if class_name
|
75
75
|
parser.document.filter = class_name.is_a?(Symbol) ? class_name.to_s : class_name
|
@@ -79,13 +79,6 @@ module Appium
|
|
79
79
|
end
|
80
80
|
end
|
81
81
|
|
82
|
-
# Gets the JSON source of window number
|
83
|
-
# @return [JSON]
|
84
|
-
def source_window(_window_number = nil)
|
85
|
-
warn '[DEPRECATION] source_window will be removed. Please use source instead.'
|
86
|
-
get_source
|
87
|
-
end
|
88
|
-
|
89
82
|
# Find by id
|
90
83
|
# @param id [String] the id to search for
|
91
84
|
# @return [Element]
|
data/lib/appium_lib/version.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
module Appium
|
2
2
|
# Version and Date are defined on the 'Appium' module, not 'Appium::Common'
|
3
|
-
VERSION = '9.
|
4
|
-
DATE = '2017-
|
3
|
+
VERSION = '9.8.1'.freeze unless defined? ::Appium::VERSION
|
4
|
+
DATE = '2017-12-16'.freeze unless defined? ::Appium::DATE
|
5
5
|
end
|
data/readme.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
# appium_lib
|
2
2
|
|
3
3
|
[![Gem Version](https://badge.fury.io/rb/appium_lib.svg)](http://badge.fury.io/rb/appium_lib)
|
4
4
|
[![Dependency Status](https://gemnasium.com/appium/ruby_lib.svg)](https://gemnasium.com/appium/ruby_lib)
|
@@ -10,22 +10,29 @@
|
|
10
10
|
|
11
11
|
- [appium_lib on RubyGems](https://rubygems.org/gems/appium_lib)
|
12
12
|
- [Documentation for appium_lib](https://github.com/appium/ruby_lib/tree/master/docs)
|
13
|
-
- [
|
13
|
+
- [Documentation for core lib](http://www.rubydoc.info/github/appium/ruby_lib_core)
|
14
|
+
- Especially [driver method for Appium](http://www.rubydoc.info/github/appium/ruby_lib_core/Appium/Core/Device)
|
14
15
|
- [Getting Started](https://github.com/appium/appium/blob/master/docs/en/about-appium/getting-started.md)
|
15
16
|
- [code examples](https://github.com/appium/sample-code/tree/master/sample-code/examples/ruby)
|
16
17
|
|
17
18
|
Helper methods for writing cross platform (iOS, Android) tests in Ruby using Appium. Note that user waits should not exceed 120 seconds if they're going to run on Sauce Labs.
|
18
19
|
|
19
|
-
|
20
|
+
[Ruby_lib_core](https://github.com/appium/ruby_lib_core) is the core driver library which provide `selenium-webdriver` related features and driver methods for Appium.
|
21
|
+
The `ruby_lib` wrap the driver and serve many helpful methods for users.
|
20
22
|
|
21
|
-
|
23
|
+
# Setup
|
24
|
+
## Requirement
|
25
|
+
- [Appium](https://github.com/appium/appium#requirements)
|
26
|
+
- Ruby: 2.2+
|
27
|
+
|
28
|
+
## Start appium server
|
22
29
|
|
23
30
|
```bash
|
24
31
|
$ npm install -g appium
|
25
32
|
$ appium
|
26
33
|
```
|
27
34
|
|
28
|
-
|
35
|
+
## Install / Upgrade
|
29
36
|
- Update rubygems and bundler
|
30
37
|
```bash
|
31
38
|
$ gem update --system
|
@@ -38,7 +45,7 @@ gem uninstall -aIx appium_lib
|
|
38
45
|
gem install --no-rdoc --no-ri appium_lib
|
39
46
|
```
|
40
47
|
|
41
|
-
|
48
|
+
## [Sauce Labs env vars](https://github.com/appium/ruby_lib/blob/master/lib/appium_lib/sauce_labs.rb)
|
42
49
|
|
43
50
|
- `SAUCE_USERNAME` Sauce username
|
44
51
|
- `SAUCE_ACCESS_KEY` Sauce API key
|
@@ -46,7 +53,7 @@ gem install --no-rdoc --no-ri appium_lib
|
|
46
53
|
|
47
54
|
(Note: If these variables are set, all tests will use Sauce Labs unless over-ridden in configuration.)
|
48
55
|
|
49
|
-
|
56
|
+
# Documentation
|
50
57
|
|
51
58
|
- [Installing Appium on OS X](https://github.com/appium/ruby_console/blob/master/osx.md)
|
52
59
|
- [Overview](https://github.com/appium/ruby_lib/blob/master/docs/docs.md)
|
@@ -55,5 +62,19 @@ gem install --no-rdoc --no-ri appium_lib
|
|
55
62
|
- [Tips for XCUITest for iOS](https://github.com/appium/ruby_lib/blob/master/docs/ios_xcuitest.md)
|
56
63
|
- [Appium Server docs](https://github.com/appium/appium/tree/master/docs)
|
57
64
|
|
58
|
-
|
65
|
+
# Related libraries
|
66
|
+
- [ruby_lib_core](https://github.com/appium/ruby_lib_core): Bridged commands, WebDriver dependencies
|
67
|
+
- We add new endpoints for Appium in the core library, and `ruby_lib` call the methods.
|
68
|
+
- [ruby_console](https://github.com/appium/ruby_console): Appium Ruby Console
|
69
|
+
- [appium_capybara](https://github.com/appium/appium_capybara): Gem enabling appium support in capybara
|
70
|
+
|
71
|
+
# Load Pry
|
59
72
|
`Pry.config.pager = false` is set if you have no `.pryrc` files and `Pry` is defined.
|
73
|
+
|
74
|
+
|
75
|
+
# Contribute
|
76
|
+
## How to add new commands for `driver`
|
77
|
+
- Add the new commands in [ruby_lib_core](https://github.com/appium/ruby_lib_core). [An example](https://github.com/appium/ruby_lib_core/commit/cdb02c29c8663d22d643b52fd65c8b2d1373bebb)
|
78
|
+
|
79
|
+
## How to add new helpful methods
|
80
|
+
- Add the new methods in this library
|
data/release_notes.md
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
#### v9.7.5 2017-11-04
|
2
|
+
|
3
|
+
- [1e1bb7e](https://github.com/appium/ruby_lib/commit/1e1bb7e3f1f500fa0dffe361b875b6b16941e290) [Release 9 7 5 (#717)](https://github.com/appium/ruby_lib/issues/717)
|
4
|
+
- [6a6d07e](https://github.com/appium/ruby_lib/commit/6a6d07e80686a171f76ea4fa013996e7f81f6fb9) [fix: take care capybara case (#716)](https://github.com/appium/ruby_lib/issues/716)
|
5
|
+
|
6
|
+
|
1
7
|
#### v9.7.4 2017-10-28
|
2
8
|
|
3
9
|
- [8522f49](https://github.com/appium/ruby_lib/commit/8522f496eff2a72648a563af8ce06cb8c7270256) [Release 9 7 4 (#715)](https://github.com/appium/ruby_lib/issues/715)
|
metadata
CHANGED
@@ -1,63 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: appium_lib
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 9.
|
4
|
+
version: 9.8.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- code@bootstraponline.com
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-12-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: appium_lib_core
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
20
|
-
- - ">="
|
21
|
-
- !ruby/object:Gem::Version
|
22
|
-
version: 3.4.1
|
23
|
-
type: :runtime
|
24
|
-
prerelease: false
|
25
|
-
version_requirements: !ruby/object:Gem::Requirement
|
26
|
-
requirements:
|
27
|
-
- - "~>"
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
version: '3.4'
|
30
|
-
- - ">="
|
31
|
-
- !ruby/object:Gem::Version
|
32
|
-
version: 3.4.1
|
33
|
-
- !ruby/object:Gem::Dependency
|
34
|
-
name: awesome_print
|
35
|
-
requirement: !ruby/object:Gem::Requirement
|
36
|
-
requirements:
|
37
|
-
- - "~>"
|
38
|
-
- !ruby/object:Gem::Version
|
39
|
-
version: '1.8'
|
19
|
+
version: '1.1'
|
40
20
|
type: :runtime
|
41
21
|
prerelease: false
|
42
22
|
version_requirements: !ruby/object:Gem::Requirement
|
43
23
|
requirements:
|
44
24
|
- - "~>"
|
45
25
|
- !ruby/object:Gem::Version
|
46
|
-
version: '1.
|
47
|
-
- !ruby/object:Gem::Dependency
|
48
|
-
name: json
|
49
|
-
requirement: !ruby/object:Gem::Requirement
|
50
|
-
requirements:
|
51
|
-
- - ">="
|
52
|
-
- !ruby/object:Gem::Version
|
53
|
-
version: '1.8'
|
54
|
-
type: :runtime
|
55
|
-
prerelease: false
|
56
|
-
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
requirements:
|
58
|
-
- - ">="
|
59
|
-
- !ruby/object:Gem::Version
|
60
|
-
version: '1.8'
|
26
|
+
version: '1.1'
|
61
27
|
- !ruby/object:Gem::Dependency
|
62
28
|
name: tomlrb
|
63
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -276,44 +242,6 @@ files:
|
|
276
242
|
- lib/appium_lib/common/multi_touch.rb
|
277
243
|
- lib/appium_lib/common/touch_actions.rb
|
278
244
|
- lib/appium_lib/common/wait.rb
|
279
|
-
- lib/appium_lib/core/android.rb
|
280
|
-
- lib/appium_lib/core/android/device.rb
|
281
|
-
- lib/appium_lib/core/android/espresso/bridge.rb
|
282
|
-
- lib/appium_lib/core/android/search_context.rb
|
283
|
-
- lib/appium_lib/core/android/touch.rb
|
284
|
-
- lib/appium_lib/core/android/uiautomator1/bridge.rb
|
285
|
-
- lib/appium_lib/core/android/uiautomator2/bridge.rb
|
286
|
-
- lib/appium_lib/core/android_espresso.rb
|
287
|
-
- lib/appium_lib/core/android_uiautomator2.rb
|
288
|
-
- lib/appium_lib/core/common.rb
|
289
|
-
- lib/appium_lib/core/common/base.rb
|
290
|
-
- lib/appium_lib/core/common/base/bridge.rb
|
291
|
-
- lib/appium_lib/core/common/base/capabilities.rb
|
292
|
-
- lib/appium_lib/core/common/base/command.rb
|
293
|
-
- lib/appium_lib/core/common/base/driver.rb
|
294
|
-
- lib/appium_lib/core/common/base/http_default.rb
|
295
|
-
- lib/appium_lib/core/common/base/search_context.rb
|
296
|
-
- lib/appium_lib/core/common/base/wait.rb
|
297
|
-
- lib/appium_lib/core/common/command.rb
|
298
|
-
- lib/appium_lib/core/common/device.rb
|
299
|
-
- lib/appium_lib/core/common/error.rb
|
300
|
-
- lib/appium_lib/core/common/log.rb
|
301
|
-
- lib/appium_lib/core/common/logger.rb
|
302
|
-
- lib/appium_lib/core/core.rb
|
303
|
-
- lib/appium_lib/core/device/multi_touch.rb
|
304
|
-
- lib/appium_lib/core/device/touch_actions.rb
|
305
|
-
- lib/appium_lib/core/driver.rb
|
306
|
-
- lib/appium_lib/core/ios.rb
|
307
|
-
- lib/appium_lib/core/ios/device.rb
|
308
|
-
- lib/appium_lib/core/ios/search_context.rb
|
309
|
-
- lib/appium_lib/core/ios/touch.rb
|
310
|
-
- lib/appium_lib/core/ios/uiautomation/bridge.rb
|
311
|
-
- lib/appium_lib/core/ios/uiautomation/patch.rb
|
312
|
-
- lib/appium_lib/core/ios/xcuitest/bridge.rb
|
313
|
-
- lib/appium_lib/core/ios/xcuitest/device.rb
|
314
|
-
- lib/appium_lib/core/ios/xcuitest/search_context.rb
|
315
|
-
- lib/appium_lib/core/ios_xcuitest.rb
|
316
|
-
- lib/appium_lib/core/patch.rb
|
317
245
|
- lib/appium_lib/driver.rb
|
318
246
|
- lib/appium_lib/ios/common/errors.rb
|
319
247
|
- lib/appium_lib/ios/common/helper.rb
|
@@ -1,142 +0,0 @@
|
|
1
|
-
module Appium
|
2
|
-
module Android
|
3
|
-
module Device
|
4
|
-
extend Forwardable
|
5
|
-
|
6
|
-
# @!method background_app
|
7
|
-
# Backgrounds the app for a set number of seconds.
|
8
|
-
# This is a blocking application
|
9
|
-
# @param [Integer] seconds How many seconds to background the app for.
|
10
|
-
#
|
11
|
-
# ```ruby
|
12
|
-
# background_app
|
13
|
-
# background_app(5)
|
14
|
-
# background_app(-1) #=> the app never come back. https://github.com/appium/appium/issues/7741
|
15
|
-
# ```
|
16
|
-
|
17
|
-
# @!method hide_keyboard
|
18
|
-
# Hide the onscreen keyboard
|
19
|
-
# @param [String] close_key The name of the key which closes the keyboard.
|
20
|
-
# Defaults to 'Done' for iOS(except for XCUITest).
|
21
|
-
# @param [Symbol] strategy The symbol of the strategy which closes the keyboard.
|
22
|
-
# XCUITest ignore this argument.
|
23
|
-
# Default for iOS is `:pressKey`. Default for Android is `:tapOutside`.
|
24
|
-
# ```ruby
|
25
|
-
# hide_keyboard # Close a keyboard with the 'Done' button
|
26
|
-
# hide_keyboard('Finished') # Close a keyboard with the 'Finished' button
|
27
|
-
# hide_keyboard(nil, :tapOutside) # Close a keyboard with tapping out side of keyboard
|
28
|
-
# ```
|
29
|
-
|
30
|
-
# @!method end_coverage
|
31
|
-
# Android only; Ends the test coverage and writes the results to the given path on device.
|
32
|
-
# @param [String] path Path on the device to write too.
|
33
|
-
# @param [String] intent Intent to broadcast when ending coverage.
|
34
|
-
|
35
|
-
# @!method start_activity
|
36
|
-
# Start a new activity within the current app or launch a new app and start the target activity.
|
37
|
-
#
|
38
|
-
# Android only.
|
39
|
-
# @option [String] The package owning the activity [required]
|
40
|
-
# @option [String] The target activity [required]
|
41
|
-
# @option opts [String] The package to start before the target package [optional]
|
42
|
-
# @option opts [String] The activity to start before the target activity [optional]
|
43
|
-
#
|
44
|
-
# ```ruby
|
45
|
-
# start_activity app_package: 'io.appium.android.apis',
|
46
|
-
# app_activity: '.accessibility.AccessibilityNodeProviderActivity'
|
47
|
-
# ```
|
48
|
-
|
49
|
-
# @!method set_network_connection
|
50
|
-
# Set the device network connection mode
|
51
|
-
# @param [String] path Bit mask that represent the network mode
|
52
|
-
#
|
53
|
-
# Value (Alias) | Data | Wifi | Airplane Mode
|
54
|
-
# -------------------------------------------------
|
55
|
-
# 1 (Airplane Mode) | 0 | 0 | 1
|
56
|
-
# 6 (All network on) | 1 | 1 | 0
|
57
|
-
# 4 (Data only) | 1 | 0 | 0
|
58
|
-
# 2 (Wifi only) | 0 | 1 | 0
|
59
|
-
# 0 (None) | 0 | 0 | 0
|
60
|
-
#
|
61
|
-
|
62
|
-
# @!method get_performance_data_types
|
63
|
-
# Get the information type of the system state which is supported to read such as
|
64
|
-
# cpu, memory, network, battery via adb commands.
|
65
|
-
# https://github.com/appium/appium-base-driver/blob/be29aec2318316d12b5c3295e924a5ba8f09b0fb/lib/mjsonwp/routes.js#L300
|
66
|
-
#
|
67
|
-
# ```ruby
|
68
|
-
# get_performance_data_types #=> ["cpuinfo", "batteryinfo", "networkinfo", "memoryinfo"]
|
69
|
-
# ```
|
70
|
-
|
71
|
-
# @!method get_performance_data
|
72
|
-
# Get the resource usage information of the application.
|
73
|
-
# https://github.com/appium/appium-base-driver/blob/be29aec2318316d12b5c3295e924a5ba8f09b0fb/lib/mjsonwp/routes.js#L303
|
74
|
-
# @param [String] package_name Package name
|
75
|
-
# @param [String] data_type Data type get with `get_performance_data_types`
|
76
|
-
# @param [String] data_read_timeout Command timeout. Default is 2.
|
77
|
-
#
|
78
|
-
# ```ruby
|
79
|
-
# get_performance_data package_name: package_name, data_type: data_type, data_read_timeout: 2
|
80
|
-
# ```
|
81
|
-
class << self
|
82
|
-
def extended(_mod)
|
83
|
-
Appium::Core::Device.extend_webdriver_with_forwardable
|
84
|
-
|
85
|
-
# Android
|
86
|
-
Appium::Core::Device.add_endpoint_method(:start_activity) do
|
87
|
-
def start_activity(opts)
|
88
|
-
raise 'opts must be a hash' unless opts.is_a? Hash
|
89
|
-
app_package = opts[:app_package]
|
90
|
-
raise 'app_package is required' unless app_package
|
91
|
-
app_activity = opts[:app_activity]
|
92
|
-
raise 'app_activity is required' unless app_activity
|
93
|
-
app_wait_package = opts.fetch(:app_wait_package, '')
|
94
|
-
app_wait_activity = opts.fetch(:app_wait_activity, '')
|
95
|
-
|
96
|
-
unknown_opts = opts.keys - [:app_package, :app_activity, :app_wait_package, :app_wait_activity]
|
97
|
-
raise "Unknown options #{unknown_opts}" unless unknown_opts.empty?
|
98
|
-
|
99
|
-
execute :start_activity, {}, appPackage: app_package,
|
100
|
-
appActivity: app_activity,
|
101
|
-
appWaitPackage: app_wait_package,
|
102
|
-
appWaitActivity: app_wait_activity
|
103
|
-
end
|
104
|
-
end
|
105
|
-
|
106
|
-
# Android, Override
|
107
|
-
Appium::Core::Device.add_endpoint_method(:hide_keyboard) do
|
108
|
-
def hide_keyboard(close_key = nil, strategy = nil)
|
109
|
-
option = {}
|
110
|
-
|
111
|
-
option[:key] = close_key if close_key
|
112
|
-
option[:strategy] = strategy || :tapOutside # default to pressKey
|
113
|
-
|
114
|
-
execute :hide_keyboard, {}, option
|
115
|
-
end
|
116
|
-
end
|
117
|
-
|
118
|
-
# TODO: TEST ME
|
119
|
-
Appium::Core::Device.add_endpoint_method(:end_coverage) do
|
120
|
-
def end_coverage(path, intent)
|
121
|
-
execute :end_coverage, {}, path: path, intent: intent
|
122
|
-
end
|
123
|
-
end
|
124
|
-
|
125
|
-
Appium::Core::Device.add_endpoint_method(:set_network_connection) do
|
126
|
-
def set_network_connection(mode)
|
127
|
-
execute :set_network_connection, {}, type: mode
|
128
|
-
end
|
129
|
-
end
|
130
|
-
|
131
|
-
Appium::Core::Device.add_endpoint_method(:get_performance_data) do
|
132
|
-
def get_performance_data(package_name:, data_type:, data_read_timeout: 1000)
|
133
|
-
execute :get_performance_data, {}, packageName: package_name,
|
134
|
-
dataType: data_type,
|
135
|
-
dataReadTimeout: data_read_timeout
|
136
|
-
end
|
137
|
-
end
|
138
|
-
end
|
139
|
-
end
|
140
|
-
end # module Device
|
141
|
-
end # module Android
|
142
|
-
end # module Appium
|