appium_lib_core 4.1.0 → 5.8.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 (66) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +187 -273
  3. data/README.md +32 -12
  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 +315 -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/common/base/remote_status.rb +31 -0
  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 -5
  21. data/lib/appium_lib_core/common/base.rb +1 -3
  22. data/lib/appium_lib_core/common/command.rb +255 -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 -6
  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 +166 -97
  36. data/lib/appium_lib_core/{patch.rb → element.rb} +66 -9
  37. data/lib/appium_lib_core/ios/uiautomation/patch.rb +1 -1
  38. data/lib/appium_lib_core/{common/base/command.rb → mac2/bridge.rb} +9 -8
  39. data/lib/appium_lib_core/mac2/device/screen.rb +48 -0
  40. data/lib/appium_lib_core/mac2/device.rb +92 -0
  41. data/lib/appium_lib_core/mac2.rb +17 -0
  42. data/lib/appium_lib_core/version.rb +2 -2
  43. data/lib/appium_lib_core/windows/device/app_management.rb +38 -0
  44. data/lib/appium_lib_core/windows/device.rb +2 -0
  45. data/lib/appium_lib_core.rb +20 -10
  46. metadata +30 -82
  47. data/.github/ISSUE_TEMPLATE/issue-report.md +0 -29
  48. data/.github/contributing.md +0 -26
  49. data/.github/issue_template.md +0 -20
  50. data/.github/workflows/unittest.yml +0 -68
  51. data/.gitignore +0 -18
  52. data/.rubocop.yml +0 -58
  53. data/azure-pipelines.yml +0 -15
  54. data/ci-jobs/functional/android_setup.yml +0 -3
  55. data/ci-jobs/functional/ios_setup.yml +0 -7
  56. data/ci-jobs/functional/publish_test_result.yml +0 -18
  57. data/ci-jobs/functional/run_appium.yml +0 -25
  58. data/ci-jobs/functional/start-emulator.sh +0 -26
  59. data/ci-jobs/functional_test.yml +0 -298
  60. data/docs/mobile_command.md +0 -34
  61. data/lib/appium_lib_core/common/base/bridge/mjsonwp.rb +0 -81
  62. data/lib/appium_lib_core/common/base/bridge/w3c.rb +0 -252
  63. data/lib/appium_lib_core/common/command/common.rb +0 -110
  64. data/lib/appium_lib_core/common/command/w3c.rb +0 -56
  65. data/release_notes.md +0 -816
  66. 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
@@ -28,17 +35,19 @@ $ bundle exec parallel_test test/unit/
28
35
  ### Functional Tests
29
36
  Run functional tests which require the Appium server and real device, Simulator/Emulator.
30
37
 
31
- - Start Appium server
38
+ - Start Appium server (Appium 2.0 base)
32
39
  ```bash
33
- $ npm install -g appium opencv4nodejs
34
- $ appium --relaxed-security # To run all tests in local
40
+ $ npm install -g appium@next
41
+ $ appium driver install xcuitest
42
+ $ appium driver install uiautomator2 # etc
43
+ $ appium --base-path=/wd/hub --relaxed-security # To run all tests in local
35
44
  ```
36
45
 
37
46
  - Conduct tests
38
47
  ```bash
39
48
  $ bundle install
40
49
  $ rake test:func:android # Andorid, uiautomator2
41
- $ AUTOMATION_NAME_DROID=espresso rake test:func:android # Andorid, uiautomator2
50
+ $ APPIUM_DRIVER=espresso rake test:func:android # Andorid, uiautomator2
42
51
  $ rake test:func:ios # iOS
43
52
  ```
44
53
 
@@ -78,7 +87,7 @@ $ PARALLEL=1 bundle exec parallel_test test/functional/ios -n 2
78
87
 
79
88
  - Runs on CI environment (on Azure)
80
89
  - 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
90
+ - `IGNORE_VERSION_SKIP=false` skips the following tests if the Appium version is lower than the requirement
82
91
 
83
92
  ```
84
93
  $ IGNORE_VERSION_SKIP=true CI=true bundle exec rake test:func:android
@@ -92,10 +101,10 @@ $ IGNORE_VERSION_SKIP=true CI=true bundle exec rake test:func:android
92
101
  ```ruby
93
102
  require 'rubygems'
94
103
  require 'appium_lib_core'
95
-
104
+
96
105
  opts = {
97
- desired_capabilities: { # or { caps: {....} }
98
- platformName: :ios,
106
+ capabilities: { # Append capabilities
107
+ platformName: 'ios',
99
108
  platformVersion: '11.0',
100
109
  deviceName: 'iPhone Simulator',
101
110
  automationName: 'XCUITest',
@@ -107,7 +116,7 @@ $ IGNORE_VERSION_SKIP=true CI=true bundle exec rake test:func:android
107
116
  }
108
117
  @core = Appium::Core.for(opts) # create a core driver with `opts`
109
118
  @driver = @core.start_driver
110
-
119
+
111
120
  # Launch iPhone Simulator and `MyiOS.app`
112
121
  @driver.find_element(:accessibility_id, 'some accessibility') # find an element
113
122
  ```
@@ -115,12 +124,23 @@ $ IGNORE_VERSION_SKIP=true CI=true bundle exec rake test:func:android
115
124
  ```bash
116
125
  # shell 1
117
126
  $ appium --log-level warn:error # show only warning and error logs
118
-
127
+
119
128
  # shell 2
120
129
  $ ruby test.rb
121
130
  ```
122
131
 
123
- More examples are in [test/functional](test/functional)
132
+ [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.
133
+
134
+ More examples are in [test/functional](test/functional)
135
+
136
+ As of version 5.8.0, the client can attach to an existing session. The main purpose is for debugging.
137
+
138
+ ```ruby
139
+ # @driver is the driver instance of an existing session
140
+ 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'
141
+ assert attached_driver.session_id == @driver.session_id
142
+ attached_driver.page_source
143
+ ```
124
144
 
125
145
  ### Capabilities
126
146
 
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 = '>= 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.8'
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.39.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