appium_lib_core 3.11.0 → 4.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4dd7162d340f5712d5ecef7ef6061f8b19d1ad66d528a674563b3eb315de066b
4
- data.tar.gz: 024f6ac6c493595db8251eca602e5a1976376364f84225b6c1cb8e69ca97550d
3
+ metadata.gz: 9668fe14e164d0c0c79f9d651fbc1452b0ec736965bc6da01791ea47153bc1b0
4
+ data.tar.gz: 141ee5425f08eef464d40b6fef0c1a396a5d382576100718f6d3efee1842fac0
5
5
  SHA512:
6
- metadata.gz: 26086370c36d9d98676a78e42c831bb91040d4024ecb6059a49e27b185aaa669f0b1d5fcccce8702f78d44b93436ea26c86ff92065e42d2783fed9d46e338909
7
- data.tar.gz: 7545b8db05d2259a7efc56ec3baf7fbc3b5a25929f11e6d80c951fe0005c690af51fca4f07bd2c178bf3cdfe00508a596fe56e467f7b4e678cd2c28c70369ba8
6
+ metadata.gz: bda31b12a734ce4d95d4f13517f50e3fe69deb34596a7d3cba326191325c9e42825e9dafd65975ba6a6bf65f45432698e370aa1f848f37507c15ff7a2d5237c8
7
+ data.tar.gz: e69702c72a42d84ca442294afb91087e195fb8f326a051a2796d3b829c6dd5ba143d51574ed3d14caae0f3fe2a318c86db80b23d484343bee930104ef9986742
@@ -11,7 +11,7 @@ jobs:
11
11
  strategy:
12
12
  fail-fast: false
13
13
  matrix:
14
- ruby: [2.2, 2.3, 2.4, 2.5, 2.6, 2.7]
14
+ ruby: [2.4, 2.5, 2.6, 2.7, 3.0]
15
15
 
16
16
  runs-on: ubuntu-latest
17
17
 
@@ -38,7 +38,7 @@ jobs:
38
38
  fail-fast: false
39
39
  matrix:
40
40
  # Does not add 2.7 on Windows so far since a command fails only on Windows
41
- ruby: [2.2, 2.3, 2.4, 2.5, 2.6]
41
+ ruby: [2.4, 2.5, 2.6]
42
42
 
43
43
  runs-on: windows-latest
44
44
 
@@ -1,7 +1,15 @@
1
1
  AllCops:
2
- TargetRubyVersion: 2.3
3
- Metrics/LineLength:
2
+ TargetRubyVersion: 2.4
3
+ Layout/LineLength:
4
4
  Max: 128
5
+ Layout/RescueEnsureAlignment:
6
+ Enabled: false
7
+ Layout/EmptyLinesAroundAttributeAccessor:
8
+ Enabled: false
9
+ Layout/EmptyLineBetweenDefs:
10
+ Enabled: false
11
+ Layout/HashAlignment:
12
+ Enabled: false
5
13
  Metrics/MethodLength:
6
14
  Enabled: false
7
15
  Metrics/ModuleLength:
@@ -18,9 +26,6 @@ Metrics/ParameterLists:
18
26
  Enabled: false
19
27
  Lint/NestedMethodDefinition:
20
28
  Enabled: false
21
- # TODO: Replace <<- with <<~ after dropping Ruby 2.2
22
- Layout/IndentHeredoc:
23
- Enabled: false
24
29
  Style/ZeroLengthPredicate:
25
30
  Enabled: false
26
31
  Style/Documentation:
@@ -29,12 +34,9 @@ Style/CommentedKeyword:
29
34
  Enabled: false
30
35
  Style/PercentLiteralDelimiters:
31
36
  Enabled: false
32
- Style/BracesAroundHashParameters:
33
- Enabled: false
34
37
  Style/SymbolArray:
35
38
  Enabled: false
36
- # TODO: will remove after stopping support 2.2
37
- Style/NumericPredicate:
39
+ Style/UnpackFirst:
38
40
  Enabled: false
39
41
  Naming/AccessorMethodName:
40
42
  Enabled: false
@@ -44,5 +46,13 @@ Naming/MemoizedInstanceVariableName:
44
46
  - test/**/*
45
47
  Naming/RescuedExceptionsVariableName:
46
48
  Enabled: false
47
- Layout/RescueEnsureAlignment:
49
+ Style/CaseLikeIf:
50
+ Enabled: false
51
+ Style/RedundantRegexpEscape:
52
+ Enabled: false
53
+ Style/OptionalBooleanParameter:
54
+ Enabled: false
55
+ Style/ExplicitBlockArgument:
56
+ Enabled: false
57
+ Style/KeywordParametersOrder:
48
58
  Enabled: false
@@ -10,6 +10,49 @@ Read `release_notes.md` for commit level details.
10
10
 
11
11
  ### Deprecations
12
12
 
13
+ ## [4.2.0] - 2021-01-02
14
+
15
+ ### Enhancements
16
+ - Add `Element#screenshot`, `Element#screenshot_as` and `Element#save_screenshot` in Element module
17
+ - `Element#screenshot_as` and `Element#save_screenshot` are same as `Driver#element_screenshot_as` and `Driver#save_element_screenshot`
18
+ - `Element#screenshot` is same as `Element#screenshot_as(:base64)`
19
+
20
+ ### Bug fixes
21
+
22
+ ### Deprecations
23
+
24
+ ## [4.1.1] - 2020-12-25
25
+
26
+ ### Enhancements
27
+ - Ruby 3.0 support
28
+ - Arguments in `@driver.execute_cdp`
29
+ - It should be like `@driver.execute_cdp 'Page.captureScreenshot', quality: 50, format: 'jpeg'` as keyword arguments
30
+ instead of `@driver.execute_cdp 'Page.captureScreenshot', { quality: 50, format: 'jpeg' }` in Ruby 3
31
+
32
+ ### Bug fixes
33
+
34
+ ### Deprecations
35
+
36
+ ## [4.0.0] - 2020-12-19
37
+
38
+ Supported Ruby version is 2.4+
39
+
40
+ ### Enhancements
41
+
42
+ ### Bug fixes
43
+
44
+ ### Deprecations
45
+ - No longer work with `forceMjsonwp` capability to force the session MJSONWP
46
+
47
+ ## [3.11.1] - 2020-11-20
48
+
49
+ ### Enhancements
50
+
51
+ ### Bug fixes
52
+ - Fix `install_app` to be able to set no args for options
53
+
54
+ ### Deprecations
55
+
13
56
  ## [3.11.0] - 2020-08-01
14
57
 
15
58
  ### Enhancements
data/README.md CHANGED
@@ -2,7 +2,7 @@
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/kazucocoa/ruby_lib_core/_apis/build/status/ruby_lib_core?branchName=master)](https://dev.azure.com/kazucocoa/ruby_lib_core/_build/latest?definitionId=9&branchName=master)
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)
6
6
 
7
7
  This library is a Ruby client for Appium. The gem is available via [appium_lib_core](https://rubygems.org/gems/appium_lib_core).
8
8
 
@@ -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.2'
7
+ spec.required_ruby_version = '>= 2.4'
8
8
 
9
9
  spec.name = 'appium_lib_core'
10
10
  spec.version = Appium::Core::VERSION
@@ -30,8 +30,8 @@ Gem::Specification.new do |spec|
30
30
  spec.add_development_dependency 'yard', '~> 0.9.11'
31
31
  spec.add_development_dependency 'minitest', '~> 5.0'
32
32
  spec.add_development_dependency 'minitest-reporters', '~> 1.1'
33
- spec.add_development_dependency 'webmock', '~> 3.8.0'
34
- spec.add_development_dependency 'rubocop', '0.68.1'
33
+ spec.add_development_dependency 'webmock', '~> 3.11.0'
34
+ spec.add_development_dependency 'rubocop', '1.7.0'
35
35
  spec.add_development_dependency 'appium_thor', '~> 1.0'
36
36
  spec.add_development_dependency 'pry'
37
37
  spec.add_development_dependency 'pry-byebug'
@@ -3,3 +3,5 @@ steps:
3
3
  displayName: Xcode Select ${{ parameters.xcodeVersion }}
4
4
  - script: xcrun simctl list
5
5
  displayName: List Installed Simulators
6
+ - script: defaults write com.apple.iphonesimulator PasteboardAutomaticSync -bool false
7
+ displayName: Disable pasteboard automatic sync
@@ -11,11 +11,14 @@ steps:
11
11
  displayName: Installed node dependencies
12
12
  - task: UseRubyVersion@0
13
13
  inputs:
14
- versionSpec: '2.4' # so far, bundler does not work over 2.5 since it raises openssl error
14
+ versionSpec: '2.7'
15
15
  - script: |
16
16
  mkdir -p test/report
17
17
  nohup appium --relaxed-security --log-timestamp --log-no-colors > test/report/appium.out 2>&1 &
18
18
  displayName: Run Appium in background
19
+ env:
20
+ JAVA_HOME: $(JAVA_HOME_11_X64)
21
+ PATH: $(JAVA_HOME_11_X64)/bin:$(PATH)
19
22
  - script: |
20
23
  gem install bundler;
21
24
  bundle install --retry=3 --jobs=4 --path vendor/bundle;
@@ -18,7 +18,7 @@ echo ${ANDROID_HOME}/emulator/emulator -list-avds
18
18
  echo "Starting emulator"
19
19
 
20
20
  # Start emulator in background
21
- nohup ${ANDROID_HOME}/emulator/emulator -avd testemulator -accel auto -no-boot-anim -no-snapshot > /dev/null 2>&1 &
21
+ nohup ${ANDROID_HOME}/emulator/emulator -avd testemulator -accel auto -no-boot-anim -gpu auto -no-snapshot > /dev/null 2>&1 &
22
22
  ${ANDROID_HOME}/platform-tools/adb wait-for-device shell 'while [[ -z $(getprop sys.boot_completed | tr -d '\r') ]]; do sleep 1; done; input keyevent 82'
23
23
 
24
24
  ${ANDROID_HOME}/platform-tools/adb devices
@@ -2,10 +2,9 @@
2
2
  parameters:
3
3
  vmImage: 'macOS-10.15'
4
4
  vmImageForIOS: 'macOS-10.15' # Not sure the reason, but macOS 10.14 instance raises no info.plist error
5
- xcodeForIOS: 11.5
6
- xcodeForTVOS: 11.5
5
+ xcodeForIOS: 12.2
6
+ xcodeForTVOS: 12.2
7
7
  androidSDK: 30
8
- androidBuildToolsVersion: '28.0.3'
9
8
  appiumVersion: 'beta'
10
9
  ignoreVersionSkip: true
11
10
  CI: true
@@ -155,7 +154,6 @@ jobs:
155
154
  ANDROID_SDK_VERSION: ${{ parameters.androidSDK }}
156
155
  IGNORE_VERSION_SKIP: ${{ parameters.ignoreVersionSkip }}
157
156
  APPIUM_VERSION: ${{ parameters.appiumVersion }}
158
- ANDROID_BUILD_TOOLS_VERSION: ${{ parameters.androidBuildToolsVersion }}
159
157
  strategy:
160
158
  matrix:
161
159
  uiautomator2:
@@ -177,7 +175,6 @@ jobs:
177
175
  ANDROID_SDK_VERSION: ${{ parameters.androidSDK }}
178
176
  IGNORE_VERSION_SKIP: ${{ parameters.ignoreVersionSkip }}
179
177
  APPIUM_VERSION: ${{ parameters.appiumVersion }}
180
- ANDROID_BUILD_TOOLS_VERSION: ${{ parameters.androidBuildToolsVersion }}
181
178
  strategy:
182
179
  matrix:
183
180
  uiautomator2:
@@ -199,7 +196,6 @@ jobs:
199
196
  ANDROID_SDK_VERSION: ${{ parameters.androidSDK }}
200
197
  IGNORE_VERSION_SKIP: ${{ parameters.ignoreVersionSkip }}
201
198
  APPIUM_VERSION: ${{ parameters.appiumVersion }}
202
- ANDROID_BUILD_TOOLS_VERSION: ${{ parameters.androidBuildToolsVersion }}
203
199
  strategy:
204
200
  matrix:
205
201
  uiautomator2:
@@ -221,7 +217,6 @@ jobs:
221
217
  ANDROID_SDK_VERSION: ${{ parameters.androidSDK }}
222
218
  IGNORE_VERSION_SKIP: ${{ parameters.ignoreVersionSkip }}
223
219
  APPIUM_VERSION: ${{ parameters.appiumVersion }}
224
- ANDROID_BUILD_TOOLS_VERSION: ${{ parameters.androidBuildToolsVersion }}
225
220
  strategy:
226
221
  matrix:
227
222
  uiautomator2:
@@ -231,7 +226,7 @@ jobs:
231
226
  steps:
232
227
  - template: ./functional/android_setup.yml
233
228
  - template: ./functional/run_appium.yml
234
- - script: bundle exec rake test:func:android TESTS=test/functional/android/android/mobile_commands_test.rb,test/functional/android/android/search_context_test.rb,test/functional/android/android/mjpeg_server_test.rb
229
+ - script: bundle exec rake test:func:android TESTS=test/functional/android/android/search_context_test.rb,test/functional/android/android/mjpeg_server_test.rb
235
230
  displayName: Run tests func_test_android_android2
236
231
  - template: ./functional/publish_test_result.yml
237
232
 
@@ -243,7 +238,6 @@ jobs:
243
238
  ANDROID_SDK_VERSION: ${{ parameters.androidSDK }}
244
239
  IGNORE_VERSION_SKIP: ${{ parameters.ignoreVersionSkip }}
245
240
  APPIUM_VERSION: ${{ parameters.appiumVersion }}
246
- ANDROID_BUILD_TOOLS_VERSION: ${{ parameters.androidBuildToolsVersion }}
247
241
  strategy:
248
242
  matrix:
249
243
  uiautomator2:
@@ -266,7 +260,6 @@ jobs:
266
260
  AUTOMATION_NAME_DROID: espresso
267
261
  IGNORE_VERSION_SKIP: ${{ parameters.ignoreVersionSkip }}
268
262
  APPIUM_VERSION: ${{ parameters.appiumVersion }}
269
- ANDROID_BUILD_TOOLS_VERSION: ${{ parameters.androidBuildToolsVersion }}
270
263
  strategy:
271
264
  matrix:
272
265
  uiautomator2:
@@ -289,7 +282,6 @@ jobs:
289
282
  # ANDROID_SDK_VERSION: ${{ parameters.androidSDK }}
290
283
  # IGNORE_VERSION_SKIP: ${{ parameters.ignoreVersionSkip }}
291
284
  # APPIUM_VERSION: ${{ parameters.appiumVersion }}
292
- # ANDROID_BUILD_TOOLS_VERSION: ${{ parameters.androidBuildToolsVersion }}
293
285
  # strategy:
294
286
  # matrix:
295
287
  # uiautomator2:
@@ -34,11 +34,11 @@ module Appium
34
34
 
35
35
  hash.each_with_object({}) do |pair, acc|
36
36
  key = begin
37
- pair[0].to_sym
38
- rescue StandardError => e
39
- ::Appium::Logger.warn(e.message)
40
- pair[0]
41
- end
37
+ pair[0].to_sym
38
+ rescue StandardError => e
39
+ ::Appium::Logger.warn(e.message)
40
+ pair[0]
41
+ end
42
42
 
43
43
  value = pair[1]
44
44
  acc[key] = value.is_a?(Hash) ? symbolize_keys(value) : value
@@ -25,7 +25,7 @@ module Appium
25
25
  module Device
26
26
  extend Forwardable
27
27
 
28
- # rubocop:disable Metrics/LineLength
28
+ # rubocop:disable Layout/LineLength
29
29
 
30
30
  # @!method open_notifications
31
31
  # Open Android notifications
@@ -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
 
@@ -307,7 +307,7 @@ module Appium
307
307
  ## class << self
308
308
  ####
309
309
 
310
- # rubocop:enable Metrics/LineLength
310
+ # rubocop:enable Layout/LineLength
311
311
 
312
312
  class << self
313
313
  def extended(_mod)
@@ -60,9 +60,6 @@ module Appium
60
60
  # Creates session handling both OSS and W3C dialects.
61
61
  # Copy from Selenium::WebDriver::Remote::Bridge to keep using +merged_capabilities+ for Appium
62
62
  #
63
- # If +desired_capabilities+ has +forceMjsonwp: true+ in the capability, this bridge works with mjsonwp protocol.
64
- # If +forceMjsonwp: false+ or no the capability, it depends on server side whether this bridge works as w3c or mjsonwp.
65
- #
66
63
  # @param [::Selenium::WebDriver::Remote::W3C::Capabilities, Hash] desired_capabilities A capability
67
64
  # @return [::Selenium::WebDriver::Remote::Capabilities, ::Selenium::WebDriver::Remote::W3C::Capabilities]
68
65
  #
@@ -76,25 +73,6 @@ module Appium
76
73
  # platformVersion: '11.4',
77
74
  # deviceName: 'iPhone Simulator',
78
75
  # useNewWDA: true,
79
- # forceMjsonwp: true
80
- # },
81
- # appium_lib: {
82
- # wait: 30
83
- # }
84
- # }
85
- # core = ::Appium::Core.for(caps)
86
- # driver = core.start_driver #=> driver.dialect == :oss
87
- #
88
- # @example
89
- #
90
- # opts = {
91
- # caps: {
92
- # platformName: :ios,
93
- # automationName: 'XCUITest',
94
- # app: 'test/functional/app/UICatalog.app.zip',
95
- # platformVersion: '11.4',
96
- # deviceName: 'iPhone Simulator',
97
- # useNewWDA: true,
98
76
  # },
99
77
  # appium_lib: {
100
78
  # wait: 30
@@ -194,21 +172,17 @@ module Appium
194
172
  force_mjsonwp = desired_capabilities[FORCE_MJSONWP]
195
173
  desired_capabilities = delete_force_mjsonwp(desired_capabilities) unless force_mjsonwp.nil?
196
174
 
197
- if force_mjsonwp
198
- {
199
- desiredCapabilities: desired_capabilities
200
- }
201
- else
202
- new_caps = add_appium_prefix(desired_capabilities)
203
- w3c_capabilities = ::Selenium::WebDriver::Remote::W3C::Capabilities.from_oss(new_caps)
204
-
205
- {
206
- desiredCapabilities: desired_capabilities,
207
- capabilities: {
208
- firstMatch: [w3c_capabilities]
209
- }
175
+ ::Appium::Logger.warn "'forceMjsonwp' no longer works. Sending both W3C and MJSONWP capabilities" if force_mjsonwp
176
+
177
+ new_caps = add_appium_prefix(desired_capabilities)
178
+ w3c_capabilities = ::Selenium::WebDriver::Remote::W3C::Capabilities.from_oss(new_caps)
179
+
180
+ {
181
+ desiredCapabilities: desired_capabilities,
182
+ capabilities: {
183
+ firstMatch: [w3c_capabilities]
210
184
  }
211
- end
185
+ }
212
186
  end
213
187
  end # class Bridge
214
188
  end # class Base
@@ -27,7 +27,7 @@ module Appium
27
27
  include ::Selenium::WebDriver::DriverExtensions::HasWebStorage
28
28
 
29
29
  include ::Appium::Core::Base::SearchContext
30
- include ::Appium::Core::Base::TakeScreenshot
30
+ include ::Appium::Core::Base::TakesScreenshot
31
31
 
32
32
  # Private API.
33
33
  # Do not use this for general use. Used by flutter driver to get bridge for creating a new element
@@ -311,6 +311,7 @@ module Appium
311
311
 
312
312
  # Perform a block within the given context, then switch back to the starting context.
313
313
  # @param [String] context The context to switch to for the duration of the block.
314
+ # @param [Proc] block The block to involve within the context
314
315
  #
315
316
  # @example
316
317
  #
@@ -318,8 +319,8 @@ module Appium
318
319
  # @driver.find_element :tag, "button"
319
320
  # end # The result of 'find_element :tag, "button"'
320
321
  #
321
- def within_context(context)
322
- block_given? ? @bridge.within_context(context, &Proc.new) : @bridge.within_context(context)
322
+ def within_context(context, &block)
323
+ block_given? ? @bridge.within_context(context, &block) : @bridge.within_context(context)
323
324
  end
324
325
 
325
326
  # Change to the default context. This is equivalent to +set_context nil+.
@@ -36,7 +36,8 @@ module Appium
36
36
 
37
37
  attr_reader :additional_headers
38
38
 
39
- def initialize(open_timeout: nil, read_timeout: nil)
39
+ # override
40
+ def initialize(open_timeout: nil, read_timeout: nil) # rubocop:disable Lint/MissingSuper
40
41
  @open_timeout = open_timeout
41
42
  @read_timeout = read_timeout
42
43
  @additional_headers = {}
@@ -15,7 +15,7 @@
15
15
  module Appium
16
16
  module Core
17
17
  class Base
18
- module TakeScreenshot
18
+ module TakesScreenshot
19
19
  #
20
20
  # Save a PNG screenshot to the given path
21
21
  #
@@ -18,7 +18,6 @@ module Appium
18
18
  module SearchContext
19
19
  # referenced: ::Selenium::WebDriver::SearchContext
20
20
 
21
- # rubocop:disable Layout/AlignHash
22
21
  FINDERS = ::Selenium::WebDriver::SearchContext::FINDERS.merge(
23
22
  accessibility_id: 'accessibility id',
24
23
  image: '-image',
@@ -37,9 +36,8 @@ module Appium
37
36
  # Tizen with Tizen prefix
38
37
  tizen_uiautomation: '-tizen uiautomation'
39
38
  )
40
- # rubocop:enable Layout/AlignHash
41
39
 
42
- # rubocop:disable Metrics/LineLength
40
+ # rubocop:disable Layout/LineLength
43
41
  #
44
42
  # Find the first element matching the given arguments
45
43
  #
@@ -129,7 +127,7 @@ module Appium
129
127
  # # For Tizen
130
128
  # @driver.find_elements :tizen_uiautomation, '....'
131
129
  #
132
- # rubocop:enable Metrics/LineLength
130
+ # rubocop:enable Layout/LineLength
133
131
  def find_element(*args)
134
132
  how, what = extract_args(args)
135
133
  by = _set_by_from_finders(how)
@@ -12,7 +12,6 @@
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
14
 
15
- # rubocop:disable Layout/AlignHash
16
15
  module Appium
17
16
  module Core
18
17
  # ref: https://github.com/appium/appium-base-driver/blob/master/lib/mjsonwp/routes.js
@@ -109,4 +108,3 @@ module Appium
109
108
  end # module Commands
110
109
  end # module Core
111
110
  end # module Appium
112
- # rubocop:enable Layout/AlignHash
@@ -12,7 +12,6 @@
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
14
 
15
- # rubocop:disable Layout/AlignHash
16
15
  module Appium
17
16
  module Core
18
17
  module Commands
@@ -27,4 +26,3 @@ module Appium
27
26
  end # module Commands
28
27
  end # module Core
29
28
  end # Appium
30
- # rubocop:enable Layout/AlignHash
@@ -12,7 +12,6 @@
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
14
 
15
- # rubocop:disable Layout/AlignHash
16
15
  module Appium
17
16
  module Core
18
17
  module Commands
@@ -55,4 +54,3 @@ module Appium
55
54
  end # module Commands
56
55
  end # module Core
57
56
  end # module Appium
58
- # rubocop:enable Layout/AlignHash
@@ -34,7 +34,7 @@ module Appium
34
34
  execute :app_strings, {}, opts
35
35
  end
36
36
 
37
- def background_app(duration = 0) # rubocop:disable Lint/UnusedMethodArgument
37
+ def background_app(duration = 0)
38
38
  # Should override in each driver
39
39
  raise NotImplementedError
40
40
  end
@@ -47,7 +47,7 @@ module Appium
47
47
  grant_permissions: nil)
48
48
  args = { appPath: path }
49
49
 
50
- args[:options] = {} unless options?(replace, timeout, allow_test_packages, use_sdcard, grant_permissions)
50
+ args[:options] = {} if options?(replace, timeout, allow_test_packages, use_sdcard, grant_permissions)
51
51
 
52
52
  args[:options][:replace] = replace unless replace.nil?
53
53
  args[:options][:timeout] = timeout unless timeout.nil?
@@ -92,8 +92,8 @@ module Appium
92
92
 
93
93
  private
94
94
 
95
- def options?(replace, timeout, allow_test_packages, use_sdcard, grant_permissions)
96
- replace.nil? || timeout.nil? || allow_test_packages.nil? || use_sdcard.nil? || grant_permissions.nil?
95
+ def options?(*args)
96
+ args.compact.any?
97
97
  end
98
98
  end # module AppManagement
99
99
  end # module Device
@@ -24,8 +24,8 @@ module Appium
24
24
  # @example
25
25
  #
26
26
  # @driver = Appium::Core.for(opts).start_driver
27
- # action_1 = TouchAction.new(@driver).press(x: 45, y: 100).wait(600).release
28
- # action_2 = TouchAction.new(@driver).tap(element: el, x: 50, y:5, count: 3)
27
+ # action_1 = Appium::Core::TouchAction.new(@driver).press(x: 45, y: 100).wait(600).release
28
+ # action_2 = Appium::Core::TouchAction.new(@driver).tap(element: el, x: 50, y:5, count: 3)
29
29
  #
30
30
  # multi_touch_action = MultiTouch.new(@driver)
31
31
  # multi_touch_action.add action_1
@@ -27,9 +27,9 @@ module Appium
27
27
  # @example
28
28
  #
29
29
  # @driver = Appium::Core.for(opts).start_driver
30
- # action = TouchAction.new(@driver).press(x: 45, y: 100).wait(600).release
30
+ # action = Appium::Core::TouchAction.new(@driver).press(x: 45, y: 100).wait(600).release
31
31
  # action.perform
32
- # action = TouchAction.new(@driver).swipe(....)
32
+ # action = Appium::Core::TouchAction.new(@driver).swipe(....)
33
33
  # action.perform
34
34
  #
35
35
  class TouchAction
@@ -59,7 +59,7 @@ module Appium
59
59
  # Press down for a specific duration.
60
60
  # Alternatively, you can use +press(...).wait(...).release()+ instead of +long_press+ if duration doesn't work well.
61
61
  # https://github.com/appium/ruby_lib/issues/231#issuecomment-269895512
62
- # e.g. Appium::TouchAction.new.press(x: 280, y: 530).wait(2000).release.perform
62
+ # e.g. Appium::Core::TouchAction.new.press(x: 280, y: 530).wait(2000).release.perform
63
63
  #
64
64
  # @param opts [Hash] Options
65
65
  # @option opts [WebDriver::Element] element the element to press.
@@ -53,7 +53,7 @@ module Appium
53
53
  return yield(object)
54
54
  rescue ::Errno::ECONNREFUSED => e
55
55
  raise e
56
- rescue *ignored => last_error # rubocop:disable Lint/HandleExceptions
56
+ rescue *ignored => last_error
57
57
  # swallowed
58
58
  end
59
59
  sleep interval
@@ -98,7 +98,7 @@ module Appium
98
98
  return result if result
99
99
  rescue ::Errno::ECONNREFUSED => e
100
100
  raise e
101
- rescue *ignored => last_error # rubocop:disable Lint/HandleExceptions
101
+ rescue *ignored => last_error
102
102
  # swallowed
103
103
  end
104
104
  sleep interval
@@ -494,7 +494,7 @@ module Appium
494
494
  private
495
495
 
496
496
  # @private
497
- def extend_for(device:, automation_name:)
497
+ def extend_for(device:, automation_name:) # rubocop:disable Metrics/CyclomaticComplexity
498
498
  extend Appium::Core
499
499
  extend Appium::Core::Device
500
500
 
@@ -505,21 +505,39 @@ module Appium
505
505
  ::Appium::Core::Android::Espresso::Bridge.for self
506
506
  when :uiautomator2
507
507
  ::Appium::Core::Android::Uiautomator2::Bridge.for self
508
+ when :gecko
509
+ ::Appium::Logger.debug('Gecko Driver for Android')
508
510
  else # default and UiAutomator
509
511
  ::Appium::Core::Android::Uiautomator1::Bridge.for self
510
512
  end
511
513
  when :ios, :tvos
512
514
  case automation_name
515
+ when :safari
516
+ ::Appium::Logger.debug('SafariDriver for iOS')
513
517
  when :xcuitest
514
518
  ::Appium::Core::Ios::Xcuitest::Bridge.for self
515
519
  else # default and UIAutomation
516
520
  ::Appium::Core::Ios::Uiautomation::Bridge.for self
517
521
  end
518
522
  when :mac
519
- # no Mac specific extentions
520
- ::Appium::Logger.debug('mac')
523
+ case automation_name
524
+ when :safari
525
+ ::Appium::Logger.debug('SafariDriver for macOS')
526
+ when :gecko
527
+ ::Appium::Logger.debug('Gecko Driver for macOS')
528
+ when :mac2
529
+ ::Appium::Logger.debug('macOS XCUITest')
530
+ else
531
+ # no Mac specific extentions
532
+ ::Appium::Logger.debug('macOS Native')
533
+ end
521
534
  when :windows
522
- ::Appium::Core::Windows::Bridge.for self
535
+ case automation_name
536
+ when :gecko
537
+ ::Appium::Logger.debug('Gecko Driver for Windows')
538
+ else
539
+ ::Appium::Core::Windows::Bridge.for self
540
+ end
523
541
  when :tizen
524
542
  # https://github.com/Samsung/appium-tizen-driver
525
543
  ::Appium::Logger.debug('tizen')
@@ -531,6 +549,8 @@ module Appium
531
549
  when :mac
532
550
  # In this case also can be mac
533
551
  ::Appium::Logger.debug('mac')
552
+ when :gecko # other general platform
553
+ ::Appium::Logger.debug('Gecko Driver')
534
554
  else
535
555
  ::Appium::Logger.warn("No matched driver by platformName: #{device} and automationName: #{automation_name}")
536
556
  end
@@ -23,7 +23,7 @@ module Appium
23
23
  module Device
24
24
  extend Forwardable
25
25
 
26
- # rubocop:disable Metrics/LineLength
26
+ # rubocop:disable Layout/LineLength
27
27
 
28
28
  # @!method hide_keyboard(close_key = nil, strategy = nil)
29
29
  # Hide the onscreen keyboard
@@ -171,7 +171,7 @@ module Appium
171
171
  # @driver.battery_info #=> { state: :full, level: 0.7 }
172
172
  #
173
173
 
174
- # rubocop:enable Metrics/LineLength
174
+ # rubocop:enable Layout/LineLength
175
175
 
176
176
  ####
177
177
  ## class << self
@@ -21,6 +21,9 @@ module Appium
21
21
  # To extend Appium related SearchContext into ::Selenium::WebDriver::Element
22
22
  include ::Appium::Core::Base::SearchContext
23
23
 
24
+ # TODO: Probably can remove own TakesScreenshot since Selenium 4
25
+ include ::Appium::Core::Base::TakesScreenshot
26
+
24
27
  # Returns the value of attributes like below. Read each platform to know more details.
25
28
  #
26
29
  # uiautomator2: https://github.com/appium/appium-uiautomator2-server/blob/203cc7e57ce477f3cff5d95b135d1b3450a6033a/app/src/main/java/io/appium/uiautomator2/utils/Attribute.java#L19
@@ -99,6 +102,56 @@ module Appium
99
102
  w = driver.window_size
100
103
  ::Selenium::WebDriver::Point.new "#{center_x} / #{w.width.to_f}", "#{center_y} / #{w.height.to_f}"
101
104
  end
105
+
106
+ # Return an element screenshot as base64
107
+ #
108
+ # @return String Base 64 encoded string
109
+ #
110
+ # @example
111
+ #
112
+ # element.screenshot #=> "iVBORw0KGgoAAAANSUhEUgAABDgAAAB+CAIAAABOPDa6AAAAAX"
113
+ #
114
+ def screenshot
115
+ bridge.take_element_screenshot(self)
116
+ end
117
+
118
+ # Return an element screenshot in the given format
119
+ #
120
+ # @param [:base64, :png] format
121
+ # @return String screenshot
122
+ #
123
+ # @example
124
+ #
125
+ # element.screenshot_as :base64 #=> "iVBORw0KGgoAAAANSUhEUgAABDgAAAB+CAIAAABOPDa6AAAAAX"
126
+ #
127
+ def screenshot_as(format)
128
+ case format
129
+ when :base64
130
+ bridge.take_element_screenshot(self)
131
+ when :png
132
+ bridge.take_element_screenshot(self).unpack('m')[0]
133
+ else
134
+ raise Core::Error::UnsupportedOperationError, "unsupported format: #{format.inspect}"
135
+ end
136
+ end
137
+
138
+ # Save an element screenshot to the given path
139
+ #
140
+ # @param [String] png_path A path to save the screenshot
141
+ # @return [File] Path to the element screenshot.
142
+ #
143
+ # @example
144
+ #
145
+ # element.save_screenshot("fine_name.png")
146
+ #
147
+ def save_screenshot(png_path)
148
+ extension = File.extname(png_path).downcase
149
+ if extension != '.png'
150
+ ::Appium::Logger.warn 'name used for saved screenshot does not match file type. '\
151
+ 'It should end with .png extension'
152
+ end
153
+ File.open(png_path, 'wb') { |f| f << screenshot_as(:png) }
154
+ end
102
155
  end
103
156
  end # module Core
104
157
  end # module Appium
@@ -14,7 +14,7 @@
14
14
 
15
15
  module Appium
16
16
  module Core
17
- VERSION = '3.11.0' unless defined? ::Appium::Core::VERSION
18
- DATE = '2020-08-01' unless defined? ::Appium::Core::DATE
17
+ VERSION = '4.2.0' unless defined? ::Appium::Core::VERSION
18
+ DATE = '2021-01-02' unless defined? ::Appium::Core::DATE
19
19
  end
20
20
  end
@@ -20,7 +20,7 @@ module Appium
20
20
  module Device
21
21
  extend Forwardable
22
22
 
23
- # rubocop:disable Metrics/LineLength
23
+ # rubocop:disable Layout/LineLength
24
24
 
25
25
  # @since Appium 1.18.0
26
26
  # @!method start_recording_screen(remote_path: nil, user: nil, pass: nil, method: 'PUT', force_restart: nil, time_limit: nil, fps: nil, preset: nil, video_filter: nil, capture_clicks: nil, capture_cursor: nil, audio_input: nil)
@@ -69,7 +69,7 @@ module Appium
69
69
  # @driver.start_recording_screen capture_cursor: true, capture_clicks: true, time_limit: '260'
70
70
  #
71
71
 
72
- # rubocop:enable Metrics/LineLength
72
+ # rubocop:enable Layout/LineLength
73
73
 
74
74
  ####
75
75
  ## class << self
@@ -1,3 +1,53 @@
1
+ #### v4.2.0 2021-01-02
2
+
3
+ - [e55b2b6](https://github.com/appium/ruby_lib_core/commit/e55b2b6f7fe293091be0d3835075e66c74f3b9dd) Release 4.2.0
4
+ - [b0cd235](https://github.com/appium/ruby_lib_core/commit/b0cd235a7fb6e5a8957871650bf86962cf0e0368) feat: append screenshot in element module as well (#297)
5
+
6
+
7
+ #### v4.1.1 2020-12-25
8
+
9
+ - [3a4cf56](https://github.com/appium/ruby_lib_core/commit/3a4cf56c73a64fb10ca0b7fecc5800719838095c) Release 4.1.1
10
+ - [6b2d7dd](https://github.com/appium/ruby_lib_core/commit/6b2d7ddf027b5a9f49cbe9a7f5622eb345e2c076) fix: keyword argument in Ruby 3
11
+
12
+
13
+ #### v4.1.0 2020-12-25
14
+
15
+ - [89110a9](https://github.com/appium/ruby_lib_core/commit/89110a995b869471a134f8c45ebe8dfbaabfba63) Release 4.1.0
16
+ - [c833315](https://github.com/appium/ruby_lib_core/commit/c83331560738c0a656509516fc5f610855d5dfed) chore(deps-dev): update rubocop requirement from = 1.6.1 to = 1.7.0 (#294)
17
+ - [83d57aa](https://github.com/appium/ruby_lib_core/commit/83d57aa3ad7fd100c081ecc21ab0d5c5d40bf95f) feat: support Ruby 3 (#295)
18
+ - [e13c58f](https://github.com/appium/ruby_lib_core/commit/e13c58fe4355dcb2631f0a42248d991165f428f7) feat: bump rubocop (#293)
19
+
20
+
21
+ #### v4.0.0 2020-12-19
22
+
23
+ - [66e2306](https://github.com/appium/ruby_lib_core/commit/66e23069722d5ccd9ca10f5a1bdf2733cb249a2c) Release 4.0.0
24
+ - [4ba9098](https://github.com/appium/ruby_lib_core/commit/4ba9098188b51d3534e35b0fae9340de7100f516) feat: drop forcemjsonwp (#291)
25
+ - [5df301c](https://github.com/appium/ruby_lib_core/commit/5df301cb559eed1431cc790655dc89c22be54eb9) chore(deps-dev): update webmock requirement from ~> 3.10.0 to ~> 3.11.0 (#290)
26
+ - [76c0ff7](https://github.com/appium/ruby_lib_core/commit/76c0ff7fa540261c5793cde1f79dc14bf752fd35) feat: bump supported ruby version (#289)
27
+ - [ea5dd00](https://github.com/appium/ruby_lib_core/commit/ea5dd0008a56821750a5b256b912f252dd46b78d) test: add a few steps
28
+ - [9c56f30](https://github.com/appium/ruby_lib_core/commit/9c56f302d46b2ea5d970c79536260720a6bd25ec) docs: add full module path in example
29
+ - [f88ae2c](https://github.com/appium/ruby_lib_core/commit/f88ae2c0d6e02d40089298e8bf5ec19b2af012cd) chore: Add mac2 sample and log (#288)
30
+ - [39e4611](https://github.com/appium/ruby_lib_core/commit/39e4611adac83dee85c21893fc1f904bf828f21e) ci: bump iOS versions (#287)
31
+ - [d76ebdd](https://github.com/appium/ruby_lib_core/commit/d76ebddf0d0f664e49a616a1f94425eba887245e) docs: update badge
32
+
33
+
34
+ #### v3.11.1 2020-11-20
35
+
36
+ - [4fe582c](https://github.com/appium/ruby_lib_core/commit/4fe582c1318c2b5de83fcf87e36d1fedab8ed81a) Release 3.11.1
37
+ - [e017ebc](https://github.com/appium/ruby_lib_core/commit/e017ebcaa8c50653e2f45871465c78ad5a8ce81e) fix: install_app args options bug (#286)
38
+ - [e7b881c](https://github.com/appium/ruby_lib_core/commit/e7b881c19be1b3a9acf7d01f34f59307b8e16b89) chore(deps-dev): update webmock requirement from ~> 3.9.1 to ~> 3.10.0 (#284)
39
+ - [d1e8cb8](https://github.com/appium/ruby_lib_core/commit/d1e8cb864f00d4f4bd307b523cc205ee2a636d33) feat: add safari and geckodriver (#283)
40
+ - [569ea09](https://github.com/appium/ruby_lib_core/commit/569ea09f7777dd2508f1919ddcf9b88aba272647) test: use predicate instead of name for 'value' (#282)
41
+ - [e4d63eb](https://github.com/appium/ruby_lib_core/commit/e4d63eb82248a79b41fbbc39db5b03cc35d447cd) ci: remove duplicated test running
42
+ - [30be7dc](https://github.com/appium/ruby_lib_core/commit/30be7dca0ec3cdcafa647899447387924970df34) test: fix tests
43
+ - [94d4250](https://github.com/appium/ruby_lib_core/commit/94d4250033107ff956a2b9c1f0b30fedba286b5d) test: remove a trick
44
+ - [6605f78](https://github.com/appium/ruby_lib_core/commit/6605f78fb0d996faad7f1e21f1876eab5184d430) test: tweak test cases
45
+ - [7dbbadb](https://github.com/appium/ruby_lib_core/commit/7dbbadbda69ee2f710393768fb994e8e43adb3bb) fix lint
46
+ - [7619052](https://github.com/appium/ruby_lib_core/commit/76190523c95e3f6a1ab9a9af48d60605d2f87266) tweak test cases
47
+ - [87cb224](https://github.com/appium/ruby_lib_core/commit/87cb224a3f32261823fd5bacd9349cbe2158b54c) chore(deps-dev): update webmock requirement from ~> 3.8.0 to ~> 3.9.1 (#281)
48
+ - [577a75a](https://github.com/appium/ruby_lib_core/commit/577a75a690b6f0688dead506c26704c82ea6f2e9) ci: update for espresso (#280)
49
+
50
+
1
51
  #### v3.11.0 2020-08-01
2
52
 
3
53
  - [0ed888e](https://github.com/appium/ruby_lib_core/commit/0ed888efd87def79cdb1ca922268b466485a2261) Release 3.11.0
@@ -17,9 +17,9 @@ require './lib/appium_lib_core'
17
17
 
18
18
  module Script
19
19
  class CommandsChecker
20
- attr_reader :spec_commands
21
- attr_reader :implemented_mjsonwp_commands, :implemented_w3c_commands, :implemented_core_commands
22
- attr_reader :webdriver_oss_commands, :webdriver_w3c_commands
20
+ attr_reader :spec_commands,
21
+ :implemented_mjsonwp_commands, :implemented_w3c_commands, :implemented_core_commands,
22
+ :webdriver_oss_commands, :webdriver_w3c_commands
23
23
 
24
24
  # Set commands implemented in this core library.
25
25
  #
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: appium_lib_core
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.11.0
4
+ version: 4.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kazuaki MATSUO
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-08-01 00:00:00.000000000 Z
11
+ date: 2021-01-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: selenium-webdriver
@@ -120,28 +120,28 @@ dependencies:
120
120
  requirements:
121
121
  - - "~>"
122
122
  - !ruby/object:Gem::Version
123
- version: 3.8.0
123
+ version: 3.11.0
124
124
  type: :development
125
125
  prerelease: false
126
126
  version_requirements: !ruby/object:Gem::Requirement
127
127
  requirements:
128
128
  - - "~>"
129
129
  - !ruby/object:Gem::Version
130
- version: 3.8.0
130
+ version: 3.11.0
131
131
  - !ruby/object:Gem::Dependency
132
132
  name: rubocop
133
133
  requirement: !ruby/object:Gem::Requirement
134
134
  requirements:
135
135
  - - '='
136
136
  - !ruby/object:Gem::Version
137
- version: 0.68.1
137
+ version: 1.7.0
138
138
  type: :development
139
139
  prerelease: false
140
140
  version_requirements: !ruby/object:Gem::Requirement
141
141
  requirements:
142
142
  - - '='
143
143
  - !ruby/object:Gem::Version
144
- version: 0.68.1
144
+ version: 1.7.0
145
145
  - !ruby/object:Gem::Dependency
146
146
  name: appium_thor
147
147
  requirement: !ruby/object:Gem::Requirement
@@ -333,7 +333,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
333
333
  requirements:
334
334
  - - ">="
335
335
  - !ruby/object:Gem::Version
336
- version: '2.2'
336
+ version: '2.4'
337
337
  required_rubygems_version: !ruby/object:Gem::Requirement
338
338
  requirements:
339
339
  - - ">="