appium_lib_core 4.5.0 → 4.6.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: 27d5a8e4018e381172273c5b705a2166e8f47530101eed83ffd0ddf83e93653d
4
- data.tar.gz: 78ceb26083c9ae018101180cf13c91cd28f363e819119b6500b2d48a28273474
3
+ metadata.gz: 199c9c0821774e61120fd7f1311548d9cc0fd1521d71e3b6c207fece055d11b7
4
+ data.tar.gz: f7c96d05702e81bfee428012ece7f6cd05f6e475100fc3c3e00b51a4fbd7d732
5
5
  SHA512:
6
- metadata.gz: 5d07ce477474a38c3df1fb1bd989d9e6b28188ab21d7851bec98443940b0ea5d8b358c628998aeb1f62ca93be783c617dab3b4cf4fdf26e47e97def6467dca97
7
- data.tar.gz: 29634dc748e222cf65bc6af144656f291815e4c5eaea1fa177aa7e1543752ffbcbac0d4b206f4169ab306dd25e1d5a36c2a1b3d9b51cdef438456c27e52a7bea
6
+ metadata.gz: 792aaeb715d990eb9dc7a086cc59f8ec81c06c545d4b7203a557cf60c673cade059a391d0c06b490a43834d806735c4713ae1108668271cc4da6614a48dd7c44
7
+ data.tar.gz: ba0141ca83ea0c3e6839647b117c0cb518d5333d47f70d45a36a677aab98844903c3ff0331c3788451154d9937b95647c3bc9a87b5990baaab1d6ebb2615da88
data/CHANGELOG.md CHANGED
@@ -10,17 +10,17 @@ Read `release_notes.md` for commit level details.
10
10
 
11
11
  ### Deprecations
12
12
 
13
+ ## [4.6.0] - 2021-06-03
14
+
15
+ ### Enhancements
16
+ - Add `Appium::Core::Base::Driver#add_command` to allow you to add your own command
17
+
13
18
  ## [4.5.0] - 2021-03-14
14
19
 
15
20
  ### Enhancements
16
21
  - Add `speed` argument for `Appium::Core::Base::Driver#set_location` since Appium 1.21.0
17
22
  - Add `multiple` and `match_neighbour_threshold` arguments for `Appium::Core::Base::Driver#find_image_occurrence`
18
23
 
19
- ### Bug fixes
20
-
21
- ### Deprecations
22
-
23
-
24
24
  ## [4.4.1(4.4.0)] - 2021-02-15(2021-02-13)
25
25
 
26
26
  ### Enhancements
data/README.md CHANGED
@@ -11,6 +11,7 @@ This library wraps [selenium-webdriver](https://github.com/SeleniumHQ/selenium/w
11
11
  # Documentation
12
12
 
13
13
  - http://www.rubydoc.info/github/appium/ruby_lib_core
14
+ - You can find working API examples in test code, [test/functional](test/functional)
14
15
 
15
16
  # Related library
16
17
  - https://github.com/appium/ruby_lib
@@ -120,7 +121,7 @@ $ IGNORE_VERSION_SKIP=true CI=true bundle exec rake test:func:android
120
121
  $ ruby test.rb
121
122
  ```
122
123
 
123
- More examples are in [test/functional](test/functional)
124
+ More examples are in [test/functional](test/functional)
124
125
 
125
126
  ### Capabilities
126
127
 
@@ -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.11.0'
34
- spec.add_development_dependency 'rubocop', '1.8.1'
33
+ spec.add_development_dependency 'webmock', '~> 3.13.0'
34
+ spec.add_development_dependency 'rubocop', '1.12.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'
@@ -33,8 +33,24 @@ module Appium
33
33
  include Device::TouchActions
34
34
  include Device::ExecuteDriver
35
35
 
36
+ attr_reader :available_commands
37
+
38
+ def initialize(capabilities, session_id, **opts)
39
+ @available_commands = ::Appium::Core::Commands::MJSONWP::COMMANDS.dup
40
+ super(capabilities, session_id, **opts)
41
+ end
42
+
36
43
  def commands(command)
37
- ::Appium::Core::Commands::MJSONWP::COMMANDS[command]
44
+ @available_commands[command]
45
+ end
46
+
47
+ # command for Appium 2.0.
48
+ def add_command(method:, url:, name:, &block)
49
+ raise ::Appium::Core::Error::ArgumentError, "#{name} is already defined" if @available_commands.key? name
50
+
51
+ @available_commands[name] = [method, url]
52
+
53
+ ::Appium::Core::Device.add_endpoint_method name, &block
38
54
  end
39
55
 
40
56
  # Returns all available sessions on the Appium server instance
@@ -34,8 +34,24 @@ module Appium
34
34
  include Device::ExecuteDriver
35
35
  include Device::Orientation
36
36
 
37
+ attr_reader :available_commands
38
+
39
+ def initialize(capabilities, session_id, **opts)
40
+ @available_commands = ::Appium::Core::Commands::W3C::COMMANDS.dup
41
+ super(capabilities, session_id, **opts)
42
+ end
43
+
37
44
  def commands(command)
38
- ::Appium::Core::Commands::W3C::COMMANDS[command]
45
+ @available_commands[command]
46
+ end
47
+
48
+ # command for Appium 2.0.
49
+ def add_command(method:, url:, name:, &block)
50
+ raise ::Appium::Core::Error::ArgumentError, "#{name} is already defined" if @available_commands.key? name
51
+
52
+ @available_commands[name] = [method, url]
53
+
54
+ ::Appium::Core::Device.add_endpoint_method name, &block
39
55
  end
40
56
 
41
57
  # Returns all available sessions on the Appium server instance
@@ -76,6 +76,75 @@ module Appium
76
76
  path: path)
77
77
  end
78
78
 
79
+ AVAILABLE_METHOD = [
80
+ :get, :head, :post, :put, :delete,
81
+ :connect, :options, :trace, :patch
82
+ ].freeze
83
+ # Define a new custom method to the driver so that you can define your own method for
84
+ # drivers/plugins in Appium 2.0. Appium 2.0 and its custom drivers/plugins allow you
85
+ # to define custom commands that are not part of W3C spec.
86
+ #
87
+ # @param [Symbol] method HTTP request method as https://www.w3.org/TR/webdriver/#endpoints
88
+ # @param [string] url The url to URL template as https://www.w3.org/TR/webdriver/#endpoints.
89
+ # +:session_id+ is the placeholder of 'session id'.
90
+ # Other place holders can be specified with +:+ prefix like +:id+.
91
+ # Then, the +:id+ will be replaced with a given value as the seconds argument of +execute+
92
+ # @param [Symbol] name The name of method that is called as the driver instance method.
93
+ # @param [Proc] block The block to involve as the method
94
+ # @raise [ArgumentError] If the given +name+ is already defined or +method+ are invalid value.
95
+ #
96
+ # @example
97
+ #
98
+ # @driver.add_command(
99
+ # method: :get,
100
+ # url: 'session/:session_id/path/to/custom/url',
101
+ # name: :test_command
102
+ # )
103
+ # # Send a GET request to 'session/<session id>/path/to/custom/url'
104
+ # @driver.test_command
105
+ #
106
+ #
107
+ # @driver.add_command(
108
+ # method: :post,
109
+ # url: 'session/:session_id/path/to/custom/url',
110
+ # name: :test_command
111
+ # ) do
112
+ # def test_command(argument)
113
+ # execute(:test_command, {}, { dummy: argument })
114
+ # end
115
+ # end
116
+ # # Send a POST request to 'session/<session id>/path/to/custom/url'
117
+ # # with body "{ dummy: 1 }" as JSON object. "1" is the argument.
118
+ # # ':session_id' in the given 'url' is replaced with current 'session id'.
119
+ # @driver.test_command(1)
120
+ #
121
+ # @driver.add_command(
122
+ # method: :post,
123
+ # url: 'session/:session_id/element/:id/custom/action',
124
+ # name: :test_action_command
125
+ # ) do
126
+ # def test_action_command(element_id, action)
127
+ # execute(:test_action_command, {id: element_id}, { dummy_action: action })
128
+ # end
129
+ # end
130
+ # # Send a POST request to 'session/<session id>/element/<element id>/custom/action'
131
+ # # with body "{ dummy_action: #{action} }" as JSON object. "action" is the seconds argument.
132
+ # # ':session_id' in the given url is replaced with current 'session id'.
133
+ # # ':id' in the given url is replaced with the given 'element_id'.
134
+ # e = @driver.find_element :accessibility_id, 'an element'
135
+ # @driver.test_action_command(e.ref, 'action')
136
+ #
137
+ def add_command(method:, url:, name:, &block)
138
+ unless AVAILABLE_METHOD.include? method
139
+ raise ::Appium::Core::Error::ArgumentError, "Available method is either #{AVAILABLE_METHOD}"
140
+ end
141
+
142
+ # TODO: Remove this logger
143
+ ::Appium::Logger.info '[Experimental] this method is experimental for Appium 2.0. This interface may change.'
144
+
145
+ @bridge.add_command method: method, url: url, name: name, &block
146
+ end
147
+
79
148
  ### Methods for Appium
80
149
 
81
150
  # Lock the device
@@ -164,10 +233,24 @@ module Appium
164
233
  @bridge = bridge
165
234
  end
166
235
 
236
+ # Get appium Settings for current test session.
237
+ #
238
+ # @example
239
+ #
240
+ # @driver.settings.get
241
+ #
167
242
  def get
168
243
  @bridge.get_settings
169
244
  end
170
245
 
246
+ # Update Appium Settings for current test session
247
+ #
248
+ # @param [Hash] settings Settings to update, keys are settings, values to value to set each setting to
249
+ #
250
+ # @example
251
+ #
252
+ # @driver.settings.update({'allowInvisibleElements': true})
253
+ #
171
254
  def update(settings)
172
255
  @bridge.update_settings(settings)
173
256
  end
@@ -204,8 +287,8 @@ module Appium
204
287
  #
205
288
  # @example
206
289
  #
207
- # @driver.update_settings('allowInvisibleElements': true)
208
- # @driver.settings.update('allowInvisibleElements': true)
290
+ # @driver.update_settings({ 'allowInvisibleElements': true })
291
+ # @driver.settings.update({ 'allowInvisibleElements': true })
209
292
  # @driver.settings = { 'allowInvisibleElements': true }
210
293
  #
211
294
  def settings=(value)
@@ -27,8 +27,11 @@ module Appium
27
27
 
28
28
  class UnsupportedOperationError < CoreError; end
29
29
 
30
- # Server side error
30
+ # Server side errors
31
31
  class ServerError < CoreError; end
32
+
33
+ # ruby_lib_core library specific errors
34
+ class ArgumentError < CoreError; end
32
35
  end
33
36
  end
34
37
  end
@@ -14,7 +14,7 @@
14
14
 
15
15
  module Appium
16
16
  module Core
17
- VERSION = '4.5.0' unless defined? ::Appium::Core::VERSION
18
- DATE = '2021-03-14' unless defined? ::Appium::Core::DATE
17
+ VERSION = '4.6.0' unless defined? ::Appium::Core::VERSION
18
+ DATE = '2021-06-03' unless defined? ::Appium::Core::DATE
19
19
  end
20
20
  end
data/release_notes.md CHANGED
@@ -1,3 +1,17 @@
1
+ #### v4.6.0 2021-06-03
2
+
3
+ - [0dacfab](https://github.com/appium/ruby_lib_core/commit/0dacfab1256e1447e1f7a5974dfcf48ee0a72b9d) Release 4.6.0
4
+ - [b9f015d](https://github.com/appium/ruby_lib_core/commit/b9f015d7dea14964a0733f2385ebcff68da1e18e) feat: allow to add commands dynamically (#325)
5
+ - [3de96ee](https://github.com/appium/ruby_lib_core/commit/3de96eea133ccbcbc5c4d77adc7d67c065a5a38c) chore(deps-dev): update webmock requirement from ~> 3.12.1 to ~> 3.13.0 (#324)
6
+ - [f1a9e79](https://github.com/appium/ruby_lib_core/commit/f1a9e79f3bd4d134e125fc2ed9adcf3d085afc9a) docs: address func test code as working example
7
+ - [eb85b1b](https://github.com/appium/ruby_lib_core/commit/eb85b1b26623436cb0aae95a00fef7bc2d795520) remove ; in a test
8
+ - [1632637](https://github.com/appium/ruby_lib_core/commit/1632637fd872c0b80dfb97b8514ada6a7164eebf) chore(deps-dev): update rubocop requirement from = 1.11.0 to = 1.12.0 (#321)
9
+ - [b9e47aa](https://github.com/appium/ruby_lib_core/commit/b9e47aa9b02f060ffa91e8410ab97dc87d3640a4) docs: add docstring
10
+ - [954a2fe](https://github.com/appium/ruby_lib_core/commit/954a2feebb768a55b496a2614d9e4dd8b702fc1e) chore(deps-dev): update rubocop requirement from = 1.8.1 to = 1.11.0 (#316)
11
+ - [a5b9651](https://github.com/appium/ruby_lib_core/commit/a5b9651aa349c10bd9759fedac6f09e27012a5e5) chore(deps-dev): update webmock requirement from ~> 3.11.0 to ~> 3.12.1 (#319)
12
+ - [485c096](https://github.com/appium/ruby_lib_core/commit/485c096273178aa5e21f28d93545fd127cbb8735) test: add assertion
13
+
14
+
1
15
  #### v4.5.0 2021-03-14
2
16
 
3
17
  - [656230e](https://github.com/appium/ruby_lib_core/commit/656230e688ed86414c06efaa73bce7359933cc91) Release 4.5.0
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: 4.5.0
4
+ version: 4.6.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: 2021-03-15 00:00:00.000000000 Z
11
+ date: 2021-06-04 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.11.0
123
+ version: 3.13.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.11.0
130
+ version: 3.13.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: 1.8.1
137
+ version: 1.12.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: 1.8.1
144
+ version: 1.12.0
145
145
  - !ruby/object:Gem::Dependency
146
146
  name: appium_thor
147
147
  requirement: !ruby/object:Gem::Requirement