appium_lib_core 4.1.0 → 6.2.0

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 (67) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +207 -272
  3. data/README.md +41 -14
  4. data/Rakefile +4 -0
  5. data/appium_lib_core.gemspec +5 -8
  6. data/bin/console +0 -4
  7. data/lib/appium_lib_core/android/device/auth_finger_print.rb +2 -1
  8. data/lib/appium_lib_core/android/device.rb +4 -4
  9. data/lib/appium_lib_core/common/base/bridge.rb +311 -90
  10. data/lib/appium_lib_core/common/base/capabilities.rb +8 -9
  11. data/lib/appium_lib_core/common/base/device_ime.rb +49 -0
  12. data/lib/appium_lib_core/common/base/driver.rb +222 -187
  13. data/lib/appium_lib_core/common/base/driver_settings.rb +51 -0
  14. data/lib/appium_lib_core/common/base/has_location.rb +80 -0
  15. data/lib/appium_lib_core/common/base/has_network_connection.rb +56 -0
  16. data/lib/appium_lib_core/common/base/http_default.rb +1 -3
  17. data/lib/appium_lib_core/{ios/uiautomation/bridge.rb → common/base/remote_status.rb} +9 -8
  18. data/lib/appium_lib_core/common/base/rotable.rb +54 -0
  19. data/lib/appium_lib_core/common/base/screenshot.rb +6 -6
  20. data/lib/appium_lib_core/common/base/search_context.rb +20 -6
  21. data/lib/appium_lib_core/common/base.rb +1 -3
  22. data/lib/appium_lib_core/common/command.rb +259 -4
  23. data/lib/appium_lib_core/common/device/app_management.rb +8 -14
  24. data/lib/appium_lib_core/common/device/image_comparison.rb +12 -4
  25. data/lib/appium_lib_core/common/device/keyevent.rb +4 -4
  26. data/lib/appium_lib_core/common/{command/mjsonwp.rb → device/orientation.rb} +14 -11
  27. data/lib/appium_lib_core/common/device/touch_actions.rb +2 -0
  28. data/lib/appium_lib_core/common/device/value.rb +6 -8
  29. data/lib/appium_lib_core/common/error.rb +4 -5
  30. data/lib/appium_lib_core/common/log.rb +4 -1
  31. data/lib/appium_lib_core/common/touch_action/multi_touch.rb +19 -0
  32. data/lib/appium_lib_core/common/touch_action/touch_actions.rb +16 -2
  33. data/lib/appium_lib_core/common/wait.rb +38 -6
  34. data/lib/appium_lib_core/device.rb +1 -5
  35. data/lib/appium_lib_core/driver.rb +177 -102
  36. data/lib/appium_lib_core/{patch.rb → element.rb} +66 -9
  37. data/lib/appium_lib_core/{common/base/command.rb → mac2/bridge.rb} +9 -8
  38. data/lib/appium_lib_core/mac2/device/screen.rb +48 -0
  39. data/lib/appium_lib_core/mac2/device.rb +92 -0
  40. data/lib/appium_lib_core/{ios.rb → mac2.rb} +2 -5
  41. data/lib/appium_lib_core/version.rb +2 -2
  42. data/lib/appium_lib_core/windows/device/app_management.rb +38 -0
  43. data/lib/appium_lib_core/windows/device.rb +2 -0
  44. data/lib/appium_lib_core.rb +20 -10
  45. metadata +27 -83
  46. data/.github/ISSUE_TEMPLATE/issue-report.md +0 -29
  47. data/.github/contributing.md +0 -26
  48. data/.github/issue_template.md +0 -20
  49. data/.github/workflows/unittest.yml +0 -68
  50. data/.gitignore +0 -18
  51. data/.rubocop.yml +0 -58
  52. data/azure-pipelines.yml +0 -15
  53. data/ci-jobs/functional/android_setup.yml +0 -3
  54. data/ci-jobs/functional/ios_setup.yml +0 -7
  55. data/ci-jobs/functional/publish_test_result.yml +0 -18
  56. data/ci-jobs/functional/run_appium.yml +0 -25
  57. data/ci-jobs/functional/start-emulator.sh +0 -26
  58. data/ci-jobs/functional_test.yml +0 -298
  59. data/docs/mobile_command.md +0 -34
  60. data/lib/appium_lib_core/common/base/bridge/mjsonwp.rb +0 -81
  61. data/lib/appium_lib_core/common/base/bridge/w3c.rb +0 -252
  62. data/lib/appium_lib_core/common/command/common.rb +0 -110
  63. data/lib/appium_lib_core/common/command/w3c.rb +0 -56
  64. data/lib/appium_lib_core/ios/uiautomation/device.rb +0 -44
  65. data/lib/appium_lib_core/ios/uiautomation/patch.rb +0 -34
  66. data/release_notes.md +0 -816
  67. 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
- - http://www.rubydoc.info/github/appium/ruby_lib_core
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
@@ -25,20 +32,29 @@ $ 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 -g appium opencv4nodejs
34
- $ appium --relaxed-security # To run all tests in local
47
+ $ npm install -g appium@next
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
- $ AUTOMATION_NAME_DROID=espresso rake test:func:android # Andorid, uiautomator2
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
- desired_capabilities: { # or { caps: {....} }
98
- platformName: :ios,
113
+ capabilities: { # Append capabilities
114
+ platformName: 'ios',
99
115
  platformVersion: '11.0',
100
116
  deviceName: 'iPhone Simulator',
101
- automationName: 'XCUITest',
102
- app: '/path/to/MyiOS.app'
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,12 +131,23 @@ $ 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
- More examples are in [test/functional](test/functional)
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
 
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']
@@ -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 = '>= 2.4'
7
+ spec.required_ruby_version = Gem::Requirement.new('>= 2.7')
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', '~> 3.14', '>= 3.14.1'
25
+ spec.add_runtime_dependency 'selenium-webdriver', '~> 4.2', '< 4.9'
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.11.0'
34
- spec.add_development_dependency 'rubocop', '1.7.0'
32
+ spec.add_development_dependency 'webmock', '~> 3.18.1'
33
+ spec.add_development_dependency 'rubocop', '1.44.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, "finger_id should be integer between 1 to 10. Not #{finger_id}"
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 })
@@ -290,16 +290,16 @@ module Appium
290
290
  # @driver.finger_print 1
291
291
  #
292
292
 
293
- # @!method execute_cdp(cmd, params)
293
+ # @!method execute_cdp(cmd, **params)
294
294
  # Execute Chrome Devtools protocol commands
295
295
  # https://chromedevtools.github.io/devtools-protocol
296
296
  #
297
297
  # @param [String] cmd The name of command
298
- # @param [Hash] params The parameter for the command as hash.
298
+ # @option params The parameter for the command as keyword options.
299
299
  #
300
300
  # @example
301
301
  #
302
- # @driver.execute_cdp 'Page.captureScreenshot', { quality: 50, format: 'jpeg' }
302
+ # @driver.execute_cdp 'Page.captureScreenshot', quality: 50, format: 'jpeg'
303
303
  # @driver.execute_cdp 'Page.getResourceTree'
304
304
  #
305
305
 
@@ -415,7 +415,7 @@ module Appium
415
415
  # SeleniumWebdriver could already define this method
416
416
  return if method_defined? :execute_cdp
417
417
 
418
- def execute_cdp(cmd, params = {})
418
+ def execute_cdp(cmd, **params)
419
419
  execute :chrome_send_command, {}, { cmd: cmd, params: params }
420
420
  end
421
421
  end