appium_lib_core 4.1.0 → 7.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +250 -271
- data/README.md +65 -15
- data/Rakefile +4 -0
- data/appium_lib_core.gemspec +5 -8
- data/bin/console +0 -4
- data/lib/appium_lib_core/android/device/auth_finger_print.rb +2 -1
- data/lib/appium_lib_core/android/device.rb +45 -4
- data/lib/appium_lib_core/common/base/bridge.rb +320 -90
- data/lib/appium_lib_core/common/base/capabilities.rb +8 -9
- data/lib/appium_lib_core/common/base/device_ime.rb +49 -0
- data/lib/appium_lib_core/common/base/driver.rb +232 -191
- data/lib/appium_lib_core/common/base/driver_settings.rb +51 -0
- data/lib/appium_lib_core/common/base/has_location.rb +80 -0
- data/lib/appium_lib_core/common/base/has_network_connection.rb +56 -0
- data/lib/appium_lib_core/common/base/http_default.rb +15 -38
- data/lib/appium_lib_core/{ios/uiautomation/bridge.rb → common/base/remote_status.rb} +9 -8
- data/lib/appium_lib_core/common/base/rotable.rb +62 -0
- data/lib/appium_lib_core/common/base/screenshot.rb +8 -8
- data/lib/appium_lib_core/common/base/search_context.rb +20 -6
- data/lib/appium_lib_core/common/base.rb +1 -3
- data/lib/appium_lib_core/common/command.rb +259 -4
- data/lib/appium_lib_core/common/device/app_management.rb +8 -14
- data/lib/appium_lib_core/common/device/image_comparison.rb +12 -4
- data/lib/appium_lib_core/common/device/keyevent.rb +4 -4
- data/lib/appium_lib_core/common/{command/mjsonwp.rb → device/orientation.rb} +14 -11
- data/lib/appium_lib_core/common/device/touch_actions.rb +2 -0
- data/lib/appium_lib_core/common/device/value.rb +6 -8
- data/lib/appium_lib_core/common/error.rb +4 -5
- data/lib/appium_lib_core/common/log.rb +4 -1
- data/lib/appium_lib_core/common/touch_action/multi_touch.rb +19 -0
- data/lib/appium_lib_core/common/touch_action/touch_actions.rb +16 -2
- data/lib/appium_lib_core/common/wait.rb +38 -6
- data/lib/appium_lib_core/device.rb +1 -5
- data/lib/appium_lib_core/driver.rb +194 -108
- data/lib/appium_lib_core/{patch.rb → element.rb} +66 -9
- data/lib/appium_lib_core/{common/base/command.rb → mac2/bridge.rb} +9 -8
- data/lib/appium_lib_core/mac2/device/screen.rb +48 -0
- data/lib/appium_lib_core/mac2/device.rb +92 -0
- data/lib/appium_lib_core/{ios.rb → mac2.rb} +2 -5
- data/lib/appium_lib_core/support/event_firing_bridge.rb +57 -0
- data/lib/appium_lib_core/version.rb +2 -2
- data/lib/appium_lib_core/windows/device/app_management.rb +38 -0
- data/lib/appium_lib_core/windows/device.rb +2 -0
- data/lib/appium_lib_core.rb +21 -10
- metadata +31 -86
- data/.github/ISSUE_TEMPLATE/issue-report.md +0 -29
- data/.github/contributing.md +0 -26
- data/.github/issue_template.md +0 -20
- data/.github/workflows/unittest.yml +0 -68
- data/.gitignore +0 -18
- data/.rubocop.yml +0 -58
- data/azure-pipelines.yml +0 -15
- data/ci-jobs/functional/android_setup.yml +0 -3
- data/ci-jobs/functional/ios_setup.yml +0 -7
- data/ci-jobs/functional/publish_test_result.yml +0 -18
- data/ci-jobs/functional/run_appium.yml +0 -25
- data/ci-jobs/functional/start-emulator.sh +0 -26
- data/ci-jobs/functional_test.yml +0 -298
- data/docs/mobile_command.md +0 -34
- data/lib/appium_lib_core/common/base/bridge/mjsonwp.rb +0 -81
- data/lib/appium_lib_core/common/base/bridge/w3c.rb +0 -252
- data/lib/appium_lib_core/common/command/common.rb +0 -110
- data/lib/appium_lib_core/common/command/w3c.rb +0 -56
- data/lib/appium_lib_core/ios/uiautomation/device.rb +0 -44
- data/lib/appium_lib_core/ios/uiautomation/patch.rb +0 -34
- data/release_notes.md +0 -816
- data/script/commands.rb +0 -200
data/README.md
CHANGED
@@ -10,7 +10,14 @@ This library wraps [selenium-webdriver](https://github.com/SeleniumHQ/selenium/w
|
|
10
10
|
|
11
11
|
# Documentation
|
12
12
|
|
13
|
-
-
|
13
|
+
- https://www.rubydoc.info/gems/appium_lib_core
|
14
|
+
- You can find working API examples in test code, [test/functional](test/functional)
|
15
|
+
- Appium 2.0
|
16
|
+
- https://appium.github.io/appium/docs/en/2.0/ (Not completed yet)
|
17
|
+
|
18
|
+
# Migration from v4 to v5
|
19
|
+
|
20
|
+
Please read [`[5.0.0]`](CHANGELOG.md#500---2021-11-05) section in [CHANGELOG](CHANGELOG.md)
|
14
21
|
|
15
22
|
# Related library
|
16
23
|
- https://github.com/appium/ruby_lib
|
@@ -18,27 +25,36 @@ This library wraps [selenium-webdriver](https://github.com/SeleniumHQ/selenium/w
|
|
18
25
|
# How to start
|
19
26
|
## Run tests
|
20
27
|
### Unit Tests
|
21
|
-
Run unit tests which check each method and
|
28
|
+
Run unit tests which check each method and command, URL, using the webmock.
|
22
29
|
|
23
30
|
```bash
|
24
31
|
$ bundle install
|
25
32
|
$ bundle exec parallel_test test/unit/
|
26
33
|
```
|
27
34
|
|
35
|
+
or
|
36
|
+
|
37
|
+
```bash
|
38
|
+
$ bundle install
|
39
|
+
$ bundle exec rake test:unit
|
40
|
+
```
|
41
|
+
|
28
42
|
### Functional Tests
|
29
43
|
Run functional tests which require the Appium server and real device, Simulator/Emulator.
|
30
44
|
|
31
|
-
- Start Appium server
|
45
|
+
- Start Appium server (Appium 2.0 base)
|
32
46
|
```bash
|
33
|
-
$ npm install
|
34
|
-
$ appium
|
47
|
+
$ npm install --location=global appium
|
48
|
+
$ appium driver install xcuitest
|
49
|
+
$ appium driver install uiautomator2 # etc
|
50
|
+
$ appium --base-path=/wd/hub --relaxed-security # To run all tests in local
|
35
51
|
```
|
36
52
|
|
37
53
|
- Conduct tests
|
38
54
|
```bash
|
39
55
|
$ bundle install
|
40
56
|
$ rake test:func:android # Andorid, uiautomator2
|
41
|
-
$
|
57
|
+
$ APPIUM_DRIVER=espresso rake test:func:android # Andorid, uiautomator2
|
42
58
|
$ rake test:func:ios # iOS
|
43
59
|
```
|
44
60
|
|
@@ -78,7 +94,7 @@ $ PARALLEL=1 bundle exec parallel_test test/functional/ios -n 2
|
|
78
94
|
|
79
95
|
- Runs on CI environment (on Azure)
|
80
96
|
- Non `IGNORE_VERSION_SKIP` or `IGNORE_VERSION_SKIP=true` runs all tests ignoring `skip` them by Appium versions
|
81
|
-
- `IGNORE_VERSION_SKIP=false` skips the following tests if the Appium version is lower than the requirement
|
97
|
+
- `IGNORE_VERSION_SKIP=false` skips the following tests if the Appium version is lower than the requirement
|
82
98
|
|
83
99
|
```
|
84
100
|
$ IGNORE_VERSION_SKIP=true CI=true bundle exec rake test:func:android
|
@@ -92,14 +108,14 @@ $ IGNORE_VERSION_SKIP=true CI=true bundle exec rake test:func:android
|
|
92
108
|
```ruby
|
93
109
|
require 'rubygems'
|
94
110
|
require 'appium_lib_core'
|
95
|
-
|
111
|
+
|
96
112
|
opts = {
|
97
|
-
|
98
|
-
platformName:
|
113
|
+
capabilities: { # Append capabilities
|
114
|
+
platformName: 'ios',
|
99
115
|
platformVersion: '11.0',
|
100
116
|
deviceName: 'iPhone Simulator',
|
101
|
-
|
102
|
-
|
117
|
+
# app: '/path/to/MyiOS.app', # Without 'app' capability, an appium session starts with the home screen
|
118
|
+
automationName: 'XCUITest'
|
103
119
|
},
|
104
120
|
appium_lib: {
|
105
121
|
wait: 30
|
@@ -107,7 +123,7 @@ $ IGNORE_VERSION_SKIP=true CI=true bundle exec rake test:func:android
|
|
107
123
|
}
|
108
124
|
@core = Appium::Core.for(opts) # create a core driver with `opts`
|
109
125
|
@driver = @core.start_driver
|
110
|
-
|
126
|
+
|
111
127
|
# Launch iPhone Simulator and `MyiOS.app`
|
112
128
|
@driver.find_element(:accessibility_id, 'some accessibility') # find an element
|
113
129
|
```
|
@@ -115,18 +131,52 @@ $ IGNORE_VERSION_SKIP=true CI=true bundle exec rake test:func:android
|
|
115
131
|
```bash
|
116
132
|
# shell 1
|
117
133
|
$ appium --log-level warn:error # show only warning and error logs
|
118
|
-
|
134
|
+
|
119
135
|
# shell 2
|
120
136
|
$ ruby test.rb
|
121
137
|
```
|
122
138
|
|
123
|
-
|
139
|
+
[Appium::Core.for](https://www.rubydoc.info/github/appium/ruby_lib_core/Appium/Core/Driver#for-class_method) documentation has more example to build a new driver instance.
|
140
|
+
|
141
|
+
More examples are in [test/functional](test/functional)
|
142
|
+
|
143
|
+
As of version 5.8.0, the client can attach to an existing session. The main purpose is for debugging.
|
144
|
+
|
145
|
+
```ruby
|
146
|
+
# @driver is the driver instance of an existing session
|
147
|
+
attached_driver = ::Appium::Core::Driver.attach_to @driver.session_id, url: 'http://127.0.0.1:4723/wd/hub', automation_name: 'XCUITest', platform_name: 'ios'
|
148
|
+
assert attached_driver.session_id == @driver.session_id
|
149
|
+
attached_driver.page_source
|
150
|
+
```
|
124
151
|
|
125
152
|
### Capabilities
|
126
153
|
|
127
154
|
Read [Appium/Core/Driver](https://www.rubydoc.info/github/appium/ruby_lib_core/Appium/Core/Driver) to catch up with available capabilities.
|
128
155
|
Capabilities affect only ruby_lib is [Appium/Core/Options](https://www.rubydoc.info/github/appium/ruby_lib_core/Appium/Core/Options).
|
129
156
|
|
157
|
+
|
158
|
+
### Gives custom listener
|
159
|
+
|
160
|
+
An example to define a customer listener with [Selenium::WebDriver::Support::AbstractEventListener](https://www.selenium.dev/selenium/docs/api/rb/Selenium/WebDriver/Support/AbstractEventListener.html)
|
161
|
+
|
162
|
+
```ruby
|
163
|
+
class CustomListener < ::Selenium::WebDriver::Support::AbstractEventListener
|
164
|
+
// something
|
165
|
+
end
|
166
|
+
capabilities: {
|
167
|
+
platformName: :ios,
|
168
|
+
platformVersion: '11.0',
|
169
|
+
deviceName: 'iPhone Simulator',
|
170
|
+
automationName: 'XCUITest',
|
171
|
+
app: '/path/to/MyiOS.app'
|
172
|
+
},
|
173
|
+
appium_lib: {
|
174
|
+
listener: CustomListener.new
|
175
|
+
}
|
176
|
+
@core = Appium::Core.for capabilities: capabilities, appium_lib: appium_lib
|
177
|
+
@core.start_driver
|
178
|
+
```
|
179
|
+
|
130
180
|
# Development
|
131
181
|
- Demo app
|
132
182
|
- https://android.googlesource.com/platform/development/+/master/samples/ApiDemos
|
data/Rakefile
CHANGED
@@ -38,6 +38,7 @@ namespace :test do
|
|
38
38
|
namespace :unit do
|
39
39
|
desc('Run all iOS related unit tests in test directory')
|
40
40
|
Rake::TestTask.new(:ios) do |t|
|
41
|
+
ENV['UNIT_TEST'] = '1'
|
41
42
|
t.libs << 'test'
|
42
43
|
t.libs << 'lib'
|
43
44
|
t.test_files = FileList['test/unit/ios/**/*_test.rb']
|
@@ -45,6 +46,7 @@ namespace :test do
|
|
45
46
|
|
46
47
|
desc('Run all Android related unit tests in test directory')
|
47
48
|
Rake::TestTask.new(:android) do |t|
|
49
|
+
ENV['UNIT_TEST'] = '1'
|
48
50
|
t.libs << 'test'
|
49
51
|
t.libs << 'lib'
|
50
52
|
t.test_files = FileList['test/unit/android/**/*_test.rb']
|
@@ -52,6 +54,7 @@ namespace :test do
|
|
52
54
|
|
53
55
|
desc('Run all common related unit tests in test directory')
|
54
56
|
Rake::TestTask.new(:common) do |t|
|
57
|
+
ENV['UNIT_TEST'] = '1'
|
55
58
|
t.libs << 'test'
|
56
59
|
t.libs << 'lib'
|
57
60
|
t.test_files = FileList['test/unit/common/**/*_test.rb']
|
@@ -59,6 +62,7 @@ namespace :test do
|
|
59
62
|
|
60
63
|
desc('Run all Windows related unit tests in test directory')
|
61
64
|
Rake::TestTask.new(:windows) do |t|
|
65
|
+
ENV['UNIT_TEST'] = '1'
|
62
66
|
t.libs << 'test'
|
63
67
|
t.libs << 'lib'
|
64
68
|
t.test_files = FileList['test/unit/windows/**/*_test.rb']
|
data/appium_lib_core.gemspec
CHANGED
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
require 'appium_lib_core/version'
|
5
5
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
|
-
spec.required_ruby_version = '>=
|
7
|
+
spec.required_ruby_version = Gem::Requirement.new('>= 3.0')
|
8
8
|
|
9
9
|
spec.name = 'appium_lib_core'
|
10
10
|
spec.version = Appium::Core::VERSION
|
@@ -16,25 +16,22 @@ Gem::Specification.new do |spec|
|
|
16
16
|
spec.homepage = 'https://github.com/appium/ruby_lib_core/'
|
17
17
|
spec.license = 'Apache-2.0'
|
18
18
|
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
19
|
-
f.match(%r{^(doc|test|spec|features)
|
19
|
+
f.match(%r{(^(doc|docs|test|spec|features|ci-jobs|.github|script)/|release_notes.md|.gitignore|azure-pipelines.yml|.rubocop.yml)})
|
20
20
|
end
|
21
21
|
spec.bindir = 'exe'
|
22
22
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
23
23
|
spec.require_paths = ['lib']
|
24
24
|
|
25
|
-
spec.add_runtime_dependency 'selenium-webdriver', '~>
|
25
|
+
spec.add_runtime_dependency 'selenium-webdriver', '~> 4.2', '< 4.12'
|
26
26
|
spec.add_runtime_dependency 'faye-websocket', '~> 0.11.0'
|
27
27
|
|
28
|
-
spec.add_development_dependency 'bundler', '>= 1.14'
|
29
28
|
spec.add_development_dependency 'rake', '~> 13.0'
|
30
29
|
spec.add_development_dependency 'yard', '~> 0.9.11'
|
31
30
|
spec.add_development_dependency 'minitest', '~> 5.0'
|
32
31
|
spec.add_development_dependency 'minitest-reporters', '~> 1.1'
|
33
|
-
spec.add_development_dependency 'webmock', '~> 3.
|
34
|
-
spec.add_development_dependency 'rubocop', '1.
|
32
|
+
spec.add_development_dependency 'webmock', '~> 3.18.1'
|
33
|
+
spec.add_development_dependency 'rubocop', '1.56.0'
|
35
34
|
spec.add_development_dependency 'appium_thor', '~> 1.0'
|
36
|
-
spec.add_development_dependency 'pry'
|
37
|
-
spec.add_development_dependency 'pry-byebug'
|
38
35
|
spec.add_development_dependency 'parallel_tests'
|
39
36
|
spec.add_development_dependency 'simplecov'
|
40
37
|
end
|
data/bin/console
CHANGED
@@ -6,9 +6,5 @@ require "appium_lib_core"
|
|
6
6
|
# You can add fixtures and/or initialization code here to make experimenting
|
7
7
|
# with your gem easier. You can also use a different console, if you like.
|
8
8
|
|
9
|
-
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
-
# require "pry"
|
11
|
-
# Pry.start
|
12
|
-
|
13
9
|
require "irb"
|
14
10
|
IRB.start(__FILE__)
|
@@ -21,7 +21,8 @@ module Appium
|
|
21
21
|
::Appium::Core::Device.add_endpoint_method(:finger_print) do
|
22
22
|
def finger_print(finger_id)
|
23
23
|
unless (1..10).cover? finger_id.to_i
|
24
|
-
raise ArgumentError,
|
24
|
+
raise ::Appium::Core::Error::ArgumentError,
|
25
|
+
"finger_id should be integer between 1 to 10. Not #{finger_id}"
|
25
26
|
end
|
26
27
|
|
27
28
|
execute(:finger_print, {}, { fingerprintId: finger_id.to_i })
|
@@ -106,6 +106,43 @@ module Appium
|
|
106
106
|
# @driver.toggle_data
|
107
107
|
#
|
108
108
|
|
109
|
+
# @!method location
|
110
|
+
# Get the location of the device.
|
111
|
+
#
|
112
|
+
# @return [::Appium::Location]
|
113
|
+
#
|
114
|
+
# @example
|
115
|
+
#
|
116
|
+
# driver.location #=> ::Appium::Location.new(10, 10, 10)
|
117
|
+
#
|
118
|
+
|
119
|
+
# @!method location=
|
120
|
+
# Set the location of the device.
|
121
|
+
#
|
122
|
+
# @param [::Appium::Location] location Set the location.
|
123
|
+
#
|
124
|
+
# @example
|
125
|
+
#
|
126
|
+
# driver.location = ::Appium::Location.new(10, 10, 10)
|
127
|
+
#
|
128
|
+
|
129
|
+
# @!method set_location
|
130
|
+
# Set the location of the device.
|
131
|
+
#
|
132
|
+
# @param [String, Number] latitude Set the latitude.
|
133
|
+
# @param [String, Number] longitude Set the longitude.
|
134
|
+
# @param [String, Number] altitude Set the altitude.
|
135
|
+
# @param [String, Number] speed Set the speed to apply the location on Android real devices
|
136
|
+
# in meters/second @since Appium 1.21.0 and in knots for emulators @since Appium 1.22.0.
|
137
|
+
# @param [String, Number] satellites Sets the count of geo satellites being tracked in range 1..12 @since Appium 1.22.0.
|
138
|
+
# This number is respected on Emulators.
|
139
|
+
# @param [::Appium::Location]
|
140
|
+
#
|
141
|
+
# @example
|
142
|
+
#
|
143
|
+
# driver.set_location 10, 10, 0
|
144
|
+
#
|
145
|
+
|
109
146
|
# @!method toggle_location_services
|
110
147
|
# Switch the state of the location service
|
111
148
|
#
|
@@ -290,18 +327,22 @@ module Appium
|
|
290
327
|
# @driver.finger_print 1
|
291
328
|
#
|
292
329
|
|
293
|
-
# @!method execute_cdp(cmd, params)
|
330
|
+
# @!method execute_cdp(cmd, **params)
|
294
331
|
# Execute Chrome Devtools protocol commands
|
295
332
|
# https://chromedevtools.github.io/devtools-protocol
|
296
333
|
#
|
297
334
|
# @param [String] cmd The name of command
|
298
|
-
# @
|
335
|
+
# @option params The parameter for the command as keyword options.
|
299
336
|
#
|
300
337
|
# @example
|
301
338
|
#
|
302
|
-
# @driver.execute_cdp 'Page.captureScreenshot',
|
339
|
+
# @driver.execute_cdp 'Page.captureScreenshot', quality: 50, format: 'jpeg'
|
303
340
|
# @driver.execute_cdp 'Page.getResourceTree'
|
304
341
|
#
|
342
|
+
# # for Ruby 2,7 and 3+ compatibility
|
343
|
+
# params = {'timezoneId': 'Asia/Tokyo'}
|
344
|
+
# driver.execute_cdp 'Emulation.setTimezoneOverride', **params
|
345
|
+
#
|
305
346
|
|
306
347
|
####
|
307
348
|
## class << self
|
@@ -415,7 +456,7 @@ module Appium
|
|
415
456
|
# SeleniumWebdriver could already define this method
|
416
457
|
return if method_defined? :execute_cdp
|
417
458
|
|
418
|
-
def execute_cdp(cmd, params
|
459
|
+
def execute_cdp(cmd, **params)
|
419
460
|
execute :chrome_send_command, {}, { cmd: cmd, params: params }
|
420
461
|
end
|
421
462
|
end
|