appium_lib_core 4.1.0 → 9.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (102) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +352 -270
  3. data/README.md +68 -16
  4. data/Rakefile +8 -20
  5. data/Steepfile +11 -0
  6. data/appium_lib_core.gemspec +13 -15
  7. data/bin/console +0 -4
  8. data/lib/appium_lib_core/android/device/auth_finger_print.rb +4 -1
  9. data/lib/appium_lib_core/android/device/clipboard.rb +4 -2
  10. data/lib/appium_lib_core/android/device/emulator.rb +11 -5
  11. data/lib/appium_lib_core/android/device/network.rb +10 -0
  12. data/lib/appium_lib_core/android/device/performance.rb +3 -0
  13. data/lib/appium_lib_core/android/device/screen.rb +5 -1
  14. data/lib/appium_lib_core/android/device.rb +83 -20
  15. data/lib/appium_lib_core/common/base/bridge.rb +238 -95
  16. data/lib/appium_lib_core/common/base/capabilities.rb +21 -8
  17. data/lib/appium_lib_core/common/{command/mjsonwp.rb → base/device_ime.rb} +33 -12
  18. data/lib/appium_lib_core/common/base/driver.rb +263 -334
  19. data/lib/appium_lib_core/common/base/driver_settings.rb +51 -0
  20. data/lib/appium_lib_core/common/base/has_location.rb +80 -0
  21. data/lib/appium_lib_core/common/base/has_network_connection.rb +56 -0
  22. data/lib/appium_lib_core/common/base/http_default.rb +22 -38
  23. data/lib/appium_lib_core/{ios/uiautomation/bridge.rb → common/base/remote_status.rb} +9 -8
  24. data/lib/appium_lib_core/common/base/rotable.rb +62 -0
  25. data/lib/appium_lib_core/common/base/screenshot.rb +10 -10
  26. data/lib/appium_lib_core/common/base/search_context.rb +98 -172
  27. data/lib/appium_lib_core/common/base.rb +1 -5
  28. data/lib/appium_lib_core/common/command.rb +244 -4
  29. data/lib/appium_lib_core/common/device/app_management.rb +2 -26
  30. data/lib/appium_lib_core/common/device/context.rb +1 -5
  31. data/lib/appium_lib_core/common/device/image_comparison.rb +27 -10
  32. data/lib/appium_lib_core/common/device/keyevent.rb +4 -4
  33. data/lib/appium_lib_core/common/device/{touch_actions.rb → orientation.rb} +6 -10
  34. data/lib/appium_lib_core/common/device/screen_record.rb +8 -2
  35. data/lib/appium_lib_core/common/error.rb +5 -5
  36. data/lib/appium_lib_core/common/log.rb +5 -4
  37. data/lib/appium_lib_core/common/wait.rb +38 -6
  38. data/lib/appium_lib_core/device.rb +3 -9
  39. data/lib/appium_lib_core/driver.rb +207 -164
  40. data/lib/appium_lib_core/{patch.rb → element.rb} +64 -26
  41. data/lib/appium_lib_core/ios/device/clipboard.rb +4 -2
  42. data/lib/appium_lib_core/ios/xcuitest/device.rb +2 -0
  43. data/lib/appium_lib_core/{common/base/command.rb → mac2/bridge.rb} +9 -8
  44. data/lib/appium_lib_core/mac2/device/screen.rb +48 -0
  45. data/lib/appium_lib_core/mac2/device.rb +92 -0
  46. data/lib/appium_lib_core/{ios.rb → mac2.rb} +2 -5
  47. data/lib/appium_lib_core/support/event_firing_bridge.rb +57 -0
  48. data/lib/appium_lib_core/version.rb +2 -2
  49. data/lib/appium_lib_core.rb +23 -10
  50. data/rbs_collection.lock.yaml +252 -0
  51. data/rbs_collection.yaml +15 -0
  52. data/sig/gems/selenium/abstract_event_listener.rbs +8 -0
  53. data/sig/gems/selenium/capabilities.rbs +8 -0
  54. data/sig/gems/selenium/common.rbs +10 -0
  55. data/sig/gems/selenium/default.rbs +10 -0
  56. data/sig/gems/selenium/driver.rbs +7 -0
  57. data/sig/gems/selenium/has_session_id.rbs +8 -0
  58. data/sig/gems/selenium/has_web_storage.rbs +8 -0
  59. data/sig/gems/selenium/uploads_files.rbs +8 -0
  60. data/sig/lib/appium_lib_core/common/base/capabilities.rbs +9 -0
  61. data/sig/lib/appium_lib_core/common/base/driver.rbs +167 -0
  62. data/sig/lib/appium_lib_core/common/base/driver_settings.rbs +15 -0
  63. data/sig/lib/appium_lib_core/common/base/has_location.rbs +13 -0
  64. data/sig/lib/appium_lib_core/common/base/has_network_connection.rbs +19 -0
  65. data/sig/lib/appium_lib_core/common/base/http_default.rbs +38 -0
  66. data/sig/lib/appium_lib_core/common/base/platform.rbs +7 -0
  67. data/sig/lib/appium_lib_core/common/base/remote_status.rbs +9 -0
  68. data/sig/lib/appium_lib_core/common/base/rotable.rbs +17 -0
  69. data/sig/lib/appium_lib_core/common/base/screenshot.rbs +19 -0
  70. data/sig/lib/appium_lib_core/common/device/battery_status.rbs +13 -0
  71. data/sig/lib/appium_lib_core/common/wait.rbs +31 -0
  72. data/sig/lib/appium_lib_core/device.rbs +21 -0
  73. data/sig/lib/appium_lib_core/driver.rbs +200 -0
  74. data/sig/lib/appium_lib_core/ios/xcuitest/device/battery.rbs +15 -0
  75. data/sig/lib/appium_lib_core/version.rbs +7 -0
  76. data/sig/lib/appium_lib_core.rbs +8 -0
  77. metadata +88 -111
  78. data/.github/ISSUE_TEMPLATE/issue-report.md +0 -29
  79. data/.github/contributing.md +0 -26
  80. data/.github/issue_template.md +0 -20
  81. data/.github/workflows/unittest.yml +0 -68
  82. data/.gitignore +0 -18
  83. data/.rubocop.yml +0 -58
  84. data/azure-pipelines.yml +0 -15
  85. data/ci-jobs/functional/android_setup.yml +0 -3
  86. data/ci-jobs/functional/ios_setup.yml +0 -7
  87. data/ci-jobs/functional/publish_test_result.yml +0 -18
  88. data/ci-jobs/functional/run_appium.yml +0 -25
  89. data/ci-jobs/functional/start-emulator.sh +0 -26
  90. data/ci-jobs/functional_test.yml +0 -298
  91. data/docs/mobile_command.md +0 -34
  92. data/lib/appium_lib_core/common/base/bridge/mjsonwp.rb +0 -81
  93. data/lib/appium_lib_core/common/base/bridge/w3c.rb +0 -252
  94. data/lib/appium_lib_core/common/command/common.rb +0 -110
  95. data/lib/appium_lib_core/common/command/w3c.rb +0 -56
  96. data/lib/appium_lib_core/common/device/value.rb +0 -52
  97. data/lib/appium_lib_core/common/touch_action/multi_touch.rb +0 -56
  98. data/lib/appium_lib_core/common/touch_action/touch_actions.rb +0 -203
  99. data/lib/appium_lib_core/ios/uiautomation/device.rb +0 -44
  100. data/lib/appium_lib_core/ios/uiautomation/patch.rb +0 -34
  101. data/release_notes.md +0 -816
  102. data/script/commands.rb +0 -200
data/README.md CHANGED
@@ -2,7 +2,9 @@
2
2
 
3
3
  [![Gem Version](https://badge.fury.io/rb/appium_lib_core.svg)](https://badge.fury.io/rb/appium_lib_core)
4
4
 
5
- [![Build Status](https://dev.azure.com/AppiumCI/Appium%20CI/_apis/build/status/appium.ruby_lib_core?branchName=master)](https://dev.azure.com/AppiumCI/Appium%20CI/_build/latest?definitionId=54&branchName=master)
5
+ [![Runs lint and unit tests](https://github.com/appium/ruby_lib_core/actions/workflows/unittest.yml/badge.svg)](https://github.com/appium/ruby_lib_core/actions/workflows/unittest.yml)
6
+ [![Functional Tests](https://github.com/appium/ruby_lib_core/actions/workflows/functional-test.yml/badge.svg)](https://github.com/appium/ruby_lib_core/actions/workflows/functional-test.yml)
7
+
6
8
 
7
9
  This library is a Ruby client for Appium. The gem is available via [appium_lib_core](https://rubygems.org/gems/appium_lib_core).
8
10
 
@@ -10,7 +12,14 @@ This library wraps [selenium-webdriver](https://github.com/SeleniumHQ/selenium/w
10
12
 
11
13
  # Documentation
12
14
 
13
- - http://www.rubydoc.info/github/appium/ruby_lib_core
15
+ - https://www.rubydoc.info/gems/appium_lib_core
16
+ - You can find working API examples in test code, [test/functional](test/functional)
17
+ - Appium 2.0
18
+ - https://appium.github.io/appium/docs/en/2.0/ (Not completed yet)
19
+
20
+ # Migration from v4 to v5
21
+
22
+ Please read [`[5.0.0]`](CHANGELOG.md#500---2021-11-05) section in [CHANGELOG](CHANGELOG.md)
14
23
 
15
24
  # Related library
16
25
  - https://github.com/appium/ruby_lib
@@ -18,27 +27,36 @@ This library wraps [selenium-webdriver](https://github.com/SeleniumHQ/selenium/w
18
27
  # How to start
19
28
  ## Run tests
20
29
  ### Unit Tests
21
- Run unit tests which check each method and commands, URL, using the webmock.
30
+ Run unit tests which check each method and command, URL, using the webmock.
22
31
 
23
32
  ```bash
24
33
  $ bundle install
25
34
  $ bundle exec parallel_test test/unit/
26
35
  ```
27
36
 
37
+ or
38
+
39
+ ```bash
40
+ $ bundle install
41
+ $ bundle exec rake test:unit
42
+ ```
43
+
28
44
  ### Functional Tests
29
45
  Run functional tests which require the Appium server and real device, Simulator/Emulator.
30
46
 
31
- - Start Appium server
47
+ - Start Appium server (Appium 2.0 base)
32
48
  ```bash
33
- $ npm install -g appium opencv4nodejs
34
- $ appium --relaxed-security # To run all tests in local
49
+ $ npm install --location=global appium
50
+ $ appium driver install xcuitest
51
+ $ appium driver install uiautomator2 # etc
52
+ $ appium --base-path=/wd/hub --relaxed-security # To run all tests in local
35
53
  ```
36
54
 
37
55
  - Conduct tests
38
56
  ```bash
39
57
  $ bundle install
40
58
  $ rake test:func:android # Andorid, uiautomator2
41
- $ AUTOMATION_NAME_DROID=espresso rake test:func:android # Andorid, uiautomator2
59
+ $ APPIUM_DRIVER=espresso rake test:func:android # Andorid, uiautomator2
42
60
  $ rake test:func:ios # iOS
43
61
  ```
44
62
 
@@ -78,7 +96,7 @@ $ PARALLEL=1 bundle exec parallel_test test/functional/ios -n 2
78
96
 
79
97
  - Runs on CI environment (on Azure)
80
98
  - 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
99
+ - `IGNORE_VERSION_SKIP=false` skips the following tests if the Appium version is lower than the requirement
82
100
 
83
101
  ```
84
102
  $ IGNORE_VERSION_SKIP=true CI=true bundle exec rake test:func:android
@@ -92,14 +110,14 @@ $ IGNORE_VERSION_SKIP=true CI=true bundle exec rake test:func:android
92
110
  ```ruby
93
111
  require 'rubygems'
94
112
  require 'appium_lib_core'
95
-
113
+
96
114
  opts = {
97
- desired_capabilities: { # or { caps: {....} }
98
- platformName: :ios,
115
+ capabilities: { # Append capabilities
116
+ platformName: 'ios',
99
117
  platformVersion: '11.0',
100
118
  deviceName: 'iPhone Simulator',
101
- automationName: 'XCUITest',
102
- app: '/path/to/MyiOS.app'
119
+ # app: '/path/to/MyiOS.app', # Without 'app' capability, an appium session starts with the home screen
120
+ automationName: 'XCUITest'
103
121
  },
104
122
  appium_lib: {
105
123
  wait: 30
@@ -107,7 +125,7 @@ $ IGNORE_VERSION_SKIP=true CI=true bundle exec rake test:func:android
107
125
  }
108
126
  @core = Appium::Core.for(opts) # create a core driver with `opts`
109
127
  @driver = @core.start_driver
110
-
128
+
111
129
  # Launch iPhone Simulator and `MyiOS.app`
112
130
  @driver.find_element(:accessibility_id, 'some accessibility') # find an element
113
131
  ```
@@ -115,18 +133,52 @@ $ IGNORE_VERSION_SKIP=true CI=true bundle exec rake test:func:android
115
133
  ```bash
116
134
  # shell 1
117
135
  $ appium --log-level warn:error # show only warning and error logs
118
-
136
+
119
137
  # shell 2
120
138
  $ ruby test.rb
121
139
  ```
122
140
 
123
- More examples are in [test/functional](test/functional)
141
+ [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.
142
+
143
+ More examples are in [test/functional](test/functional)
144
+
145
+ As of version 5.8.0, the client can attach to an existing session. The main purpose is for debugging.
146
+
147
+ ```ruby
148
+ # @driver is the driver instance of an existing session
149
+ 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'
150
+ assert attached_driver.session_id == @driver.session_id
151
+ attached_driver.page_source
152
+ ```
124
153
 
125
154
  ### Capabilities
126
155
 
127
156
  Read [Appium/Core/Driver](https://www.rubydoc.info/github/appium/ruby_lib_core/Appium/Core/Driver) to catch up with available capabilities.
128
157
  Capabilities affect only ruby_lib is [Appium/Core/Options](https://www.rubydoc.info/github/appium/ruby_lib_core/Appium/Core/Options).
129
158
 
159
+
160
+ ### Gives custom listener
161
+
162
+ 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)
163
+
164
+ ```ruby
165
+ class CustomListener < ::Selenium::WebDriver::Support::AbstractEventListener
166
+ // something
167
+ end
168
+ capabilities: {
169
+ platformName: :ios,
170
+ platformVersion: '11.0',
171
+ deviceName: 'iPhone Simulator',
172
+ automationName: 'XCUITest',
173
+ app: '/path/to/MyiOS.app'
174
+ },
175
+ appium_lib: {
176
+ listener: CustomListener.new
177
+ }
178
+ @core = Appium::Core.for capabilities: capabilities, appium_lib: appium_lib
179
+ @core.start_driver
180
+ ```
181
+
130
182
  # Development
131
183
  - Demo app
132
184
  - 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']
@@ -109,28 +113,12 @@ end
109
113
 
110
114
  desc('Execute RuboCop static code analysis')
111
115
  RuboCop::RakeTask.new(:rubocop) do |t|
112
- t.patterns = %w(lib test script)
116
+ t.patterns = %w(lib test)
113
117
  t.options = %w(-D)
114
118
  t.fail_on_error = true
115
119
  end
116
120
 
117
- desc('print commands which Ruby client has not implemented them yet')
118
- namespace :commands do
119
- require './script/commands'
120
-
121
- desc('Mobile JSON protocol')
122
- task :mjsonwp do |_t, _args|
123
- c = Script::CommandsChecker.new
124
- c.get_mjsonwp_routes
125
- c.get_all_command_path './mjsonwp_routes.js'
126
- c.all_diff_commands_mjsonwp.each { |key, value| puts("command: #{key}, method: #{value}") }
127
- end
128
-
129
- desc('W3C protocol')
130
- task :w3c do |_t, _args|
131
- c = Script::CommandsChecker.new
132
- c.get_mjsonwp_routes
133
- c.get_all_command_path './mjsonwp_routes.js'
134
- c.all_diff_commands_w3c.each { |key, value| puts("command: #{key}, method: #{value}") }
135
- end
121
+ desc('Run Steep type check')
122
+ task :steep do
123
+ system('steep check')
136
124
  end
data/Steepfile ADDED
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ target :lib do
4
+ signature 'sig'
5
+ check 'lib' # Directory name
6
+
7
+ # Standard libraries used in the project
8
+ library(
9
+ 'forwardable'
10
+ )
11
+ end
@@ -1,40 +1,38 @@
1
- # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
1
+ lib = File.expand_path('lib', __dir__)
3
2
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
3
  require 'appium_lib_core/version'
5
4
 
6
5
  Gem::Specification.new do |spec|
7
- spec.required_ruby_version = '>= 2.4'
6
+ spec.required_ruby_version = Gem::Requirement.new('>= 3.0')
8
7
 
9
8
  spec.name = 'appium_lib_core'
10
9
  spec.version = Appium::Core::VERSION
11
10
  spec.authors = ['Kazuaki MATSUO']
12
11
  spec.email = ['fly.49.89.over@gmail.com']
13
12
 
14
- spec.summary = %q{Minimal Ruby library for Appium.}
15
- spec.description = %q{Minimal Ruby library for Appium.}
13
+ spec.summary = 'Minimal Ruby library for Appium.'
14
+ spec.description = 'Minimal Ruby library for Appium.'
16
15
  spec.homepage = 'https://github.com/appium/ruby_lib_core/'
17
16
  spec.license = 'Apache-2.0'
18
17
  spec.files = `git ls-files -z`.split("\x0").reject do |f|
19
- f.match(%r{^(doc|test|spec|features)/})
18
+ f.match(%r{(^(doc|docs|test|spec|features|ci-jobs|.github|script)/|release_notes.md|.gitignore|azure-pipelines.yml|.rubocop.yml)})
20
19
  end
21
20
  spec.bindir = 'exe'
22
21
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
23
22
  spec.require_paths = ['lib']
24
23
 
25
- spec.add_runtime_dependency 'selenium-webdriver', '~> 3.14', '>= 3.14.1'
26
24
  spec.add_runtime_dependency 'faye-websocket', '~> 0.11.0'
25
+ spec.add_runtime_dependency 'selenium-webdriver', '~> 4.21'
27
26
 
28
- spec.add_development_dependency 'bundler', '>= 1.14'
29
- spec.add_development_dependency 'rake', '~> 13.0'
30
- spec.add_development_dependency 'yard', '~> 0.9.11'
27
+ spec.add_development_dependency 'appium_thor', '~> 2.0'
31
28
  spec.add_development_dependency 'minitest', '~> 5.0'
32
29
  spec.add_development_dependency 'minitest-reporters', '~> 1.1'
33
- spec.add_development_dependency 'webmock', '~> 3.11.0'
34
- spec.add_development_dependency 'rubocop', '1.7.0'
35
- spec.add_development_dependency 'appium_thor', '~> 1.0'
36
- spec.add_development_dependency 'pry'
37
- spec.add_development_dependency 'pry-byebug'
38
30
  spec.add_development_dependency 'parallel_tests'
31
+ spec.add_development_dependency 'rake', '~> 13.0'
32
+ spec.add_development_dependency 'rubocop', '1.65.1'
39
33
  spec.add_development_dependency 'simplecov'
34
+ spec.add_development_dependency 'steep', '~> 1.7.0'
35
+ spec.add_development_dependency 'webmock', '~> 3.23.0'
36
+ spec.add_development_dependency 'yard', '~> 0.9.11'
37
+ spec.metadata['rubygems_mfa_required'] = 'true'
40
38
  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__)
@@ -20,8 +20,11 @@ module Appium
20
20
  def self.add_methods
21
21
  ::Appium::Core::Device.add_endpoint_method(:finger_print) do
22
22
  def finger_print(finger_id)
23
+ ::Appium::Logger.warn "[DEPRECATION] Please use 'mobile: fingerprint' extension instead"
24
+
23
25
  unless (1..10).cover? finger_id.to_i
24
- raise ArgumentError, "finger_id should be integer between 1 to 10. Not #{finger_id}"
26
+ raise ::Appium::Core::Error::ArgumentError,
27
+ "finger_id should be integer between 1 to 10. Not #{finger_id}"
25
28
  end
26
29
 
27
30
  execute(:finger_print, {}, { fingerprintId: finger_id.to_i })
@@ -23,7 +23,8 @@ module Appium
23
23
  ::Appium::Core::Device.add_endpoint_method(:get_clipboard) do
24
24
  def get_clipboard(content_type: :plaintext)
25
25
  unless ::Appium::Core::Base::Device::Clipboard::CONTENT_TYPE.member?(content_type)
26
- raise "content_type should be #{::Appium::Core::Base::Device::Clipboard::CONTENT_TYPE}"
26
+ raise ::Appium::Core::Error::ArgumentError,
27
+ "content_type should be #{::Appium::Core::Base::Device::Clipboard::CONTENT_TYPE}"
27
28
  end
28
29
 
29
30
  params = { contentType: content_type }
@@ -36,7 +37,8 @@ module Appium
36
37
  ::Appium::Core::Device.add_endpoint_method(:set_clipboard) do
37
38
  def set_clipboard(content:, content_type: :plaintext, label: nil)
38
39
  unless ::Appium::Core::Base::Device::Clipboard::CONTENT_TYPE.member?(content_type)
39
- raise "content_type should be #{::Appium::Core::Base::Device::Clipboard::CONTENT_TYPE}"
40
+ raise ::Appium::Core::Error::ArgumentError,
41
+ "content_type should be #{::Appium::Core::Base::Device::Clipboard::CONTENT_TYPE}"
40
42
  end
41
43
 
42
44
  params = {
@@ -122,7 +122,7 @@ module Appium
122
122
  ::Appium::Core::Device.add_endpoint_method(:gsm_call) do
123
123
  def gsm_call(phone_number:, action:)
124
124
  unless GSM_CALL_ACTIONS.member? action.to_sym
125
- raise "action: should be member of #{GSM_CALL_ACTIONS}. Not #{action}."
125
+ raise ::Appium::Core::Error::ArgumentError, "action: should be member of #{GSM_CALL_ACTIONS}. Not #{action}."
126
126
  end
127
127
 
128
128
  execute(:gsm_call, {}, { phoneNumber: phone_number, action: action })
@@ -131,7 +131,10 @@ module Appium
131
131
 
132
132
  ::Appium::Core::Device.add_endpoint_method(:gsm_signal) do
133
133
  def gsm_signal(signal_strength)
134
- raise "#{signal_strength} should be member of #{GSM_SIGNALS.keys} " if GSM_SIGNALS[signal_strength.to_sym].nil?
134
+ if GSM_SIGNALS[signal_strength.to_sym].nil?
135
+ raise ::Appium::Core::Error::ArgumentError,
136
+ "#{signal_strength} should be member of #{GSM_SIGNALS.keys} "
137
+ end
135
138
 
136
139
  execute(:gsm_signal, {}, { signalStrength: GSM_SIGNALS[signal_strength],
137
140
  signalStrengh: GSM_SIGNALS[signal_strength] })
@@ -141,7 +144,7 @@ module Appium
141
144
  ::Appium::Core::Device.add_endpoint_method(:gsm_voice) do
142
145
  def gsm_voice(state)
143
146
  unless GSM_VOICE_STATES.member? state.to_sym
144
- raise "The state should be member of #{GSM_VOICE_STATES}. Not #{state}."
147
+ raise ::Appium::Core::Error::ArgumentError, "The state should be member of #{GSM_VOICE_STATES}. Not #{state}."
145
148
  end
146
149
 
147
150
  execute(:gsm_voice, {}, { state: state })
@@ -150,7 +153,10 @@ module Appium
150
153
 
151
154
  ::Appium::Core::Device.add_endpoint_method(:set_network_speed) do
152
155
  def set_network_speed(netspeed)
153
- raise "The netspeed should be member of #{NET_SPEED}. Not #{netspeed}." unless NET_SPEED.member? netspeed.to_sym
156
+ unless NET_SPEED.member? netspeed.to_sym
157
+ raise ::Appium::Core::Error::ArgumentError,
158
+ "The netspeed should be member of #{NET_SPEED}. Not #{netspeed}."
159
+ end
154
160
 
155
161
  execute(:set_network_speed, {}, { netspeed: netspeed })
156
162
  end
@@ -169,7 +175,7 @@ module Appium
169
175
  ::Appium::Core::Device.add_endpoint_method(:set_power_ac) do
170
176
  def set_power_ac(state)
171
177
  unless POWER_AC_STATE.member? state.to_sym
172
- raise "The state should be member of #{POWER_AC_STATE}. Not #{state}."
178
+ raise ::Appium::Core::Error::ArgumentError, "The state should be member of #{POWER_AC_STATE}. Not #{state}."
173
179
  end
174
180
 
175
181
  execute(:set_power_ac, {}, { state: state })
@@ -20,24 +20,32 @@ module Appium
20
20
  def self.add_methods
21
21
  ::Appium::Core::Device.add_endpoint_method(:get_network_connection) do
22
22
  def get_network_connection
23
+ ::Appium::Logger.warn "[DEPRECATION] Please use 'mobile: getConnectivity' extension instead"
24
+
23
25
  execute :get_network_connection
24
26
  end
25
27
  end
26
28
 
27
29
  ::Appium::Core::Device.add_endpoint_method(:toggle_wifi) do
28
30
  def toggle_wifi
31
+ ::Appium::Logger.warn "[DEPRECATION] Please use 'mobile: setConnectivity' extension instead"
32
+
29
33
  execute :toggle_wifi
30
34
  end
31
35
  end
32
36
 
33
37
  ::Appium::Core::Device.add_endpoint_method(:toggle_data) do
34
38
  def toggle_data
39
+ ::Appium::Logger.warn "[DEPRECATION] Please use 'mobile: setConnectivity' extension instead"
40
+
35
41
  execute :toggle_data
36
42
  end
37
43
  end
38
44
 
39
45
  ::Appium::Core::Device.add_endpoint_method(:set_network_connection) do
40
46
  def set_network_connection(mode)
47
+ ::Appium::Logger.warn "[DEPRECATION] Please use 'mobile: setConnectivity' extension instead"
48
+
41
49
  # same as ::Selenium::WebDriver::DriverExtensions::HasNetworkConnection
42
50
  # But this method accept number
43
51
  connection_type = { airplane_mode: 1, wifi: 2, data: 4, all: 6, none: 0 }
@@ -49,6 +57,8 @@ module Appium
49
57
 
50
58
  ::Appium::Core::Device.add_endpoint_method(:toggle_airplane_mode) do
51
59
  def toggle_airplane_mode
60
+ ::Appium::Logger.warn "[DEPRECATION] Please use 'mobile: setConnectivity' extension instead"
61
+
52
62
  execute :toggle_airplane_mode
53
63
  end
54
64
  alias_method :toggle_flight_mode, :toggle_airplane_mode
@@ -20,12 +20,15 @@ module Appium
20
20
  def self.add_methods
21
21
  ::Appium::Core::Device.add_endpoint_method(:get_performance_data_types) do
22
22
  def get_performance_data_types
23
+ ::Appium::Logger.warn "[DEPRECATION] Please use 'mobile: getPerformanceDataTypes' extension instead"
23
24
  execute :get_performance_data_types
24
25
  end
25
26
  end
26
27
 
27
28
  ::Appium::Core::Device.add_endpoint_method(:get_performance_data) do
28
29
  def get_performance_data(package_name:, data_type:, data_read_timeout: 1000)
30
+ ::Appium::Logger.warn "[DEPRECATION] Please use 'mobile: getPerformanceData' extension instead"
31
+
29
32
  execute(:get_performance_data, {},
30
33
  packageName: package_name, dataType: data_type, dataReadTimeout: data_read_timeout)
31
34
  end
@@ -20,6 +20,8 @@ module Appium
20
20
  def self.add_methods
21
21
  ::Appium::Core::Device.add_endpoint_method(:get_display_density) do
22
22
  def get_display_density
23
+ ::Appium::Logger.warn "[DEPRECATION] Please use 'mobile: getDisplayDensity' extension instead"
24
+
23
25
  execute :get_display_density
24
26
  end
25
27
  end
@@ -39,7 +41,9 @@ module Appium
39
41
  option[:bitRate] = bit_rate unless bit_rate.nil?
40
42
 
41
43
  unless bug_report.nil?
42
- raise 'bug_report should be true or false' unless [true, false].member?(bug_report)
44
+ unless [true, false].member?(bug_report)
45
+ raise ::Appium::Core::Error::ArgumentError, 'bug_report should be true or false'
46
+ end
43
47
 
44
48
  option[:bugReport] = bug_report
45
49
  end