appium_lib_core 12.0.1 → 12.1.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 92050dbff8ddd9ada25541591ea3bdfd8e9e45529aaa702d7ce2610b7a8f3347
4
- data.tar.gz: 9572c6c197b671c189d2532c79dea7b175ef9d704cdaf274acd5335ad4092a3d
3
+ metadata.gz: cb6226306206eafec9dbd6f2c2f1ac09c86fee48ee841be8616df8acf6ce56a5
4
+ data.tar.gz: ab63b82ecafb824a8b0edfdcbcba8d9ec0e1530e8a42f86c4c95aa95246a6871
5
5
  SHA512:
6
- metadata.gz: f45f47ab8f95dea1bcdfb26b1811288ff17cb8bda5837e5cc7bc9f47f1b3890a8637cfc4caceebf03013fe0809377d12f02eecaaa442813409fc49feb3aac8c0
7
- data.tar.gz: 1ec5c0ed972d09577eef5b01c1ec3713b52694f97dd6d596eb710c299a84f2ee9666d0dfc85a6c06e80cdb16be6561a40d7d95fabded6887ea0d360900697768
6
+ metadata.gz: 2573d787ffb963708aae21889b3f3ab6f68b7747b623a7ba906fff4065f7514557608dfaa6b9b05b8ceddaf4a6f0ae96edb20a436af01e3148c5c13ed64bf598
7
+ data.tar.gz: 21c2e01a1bdfb8bfd81ad309eb8e6fbdfa6d5abba485c77b52c257652be9c8b58a4f62a110a78128f2f26438e0d018cebfe6f1cffd8f60e1aa91293c2d14e269
data/CHANGELOG.md CHANGED
@@ -2,6 +2,9 @@
2
2
  All notable changes to this project will be documented in this file.
3
3
  Read `release_notes.md` for commit level details.
4
4
 
5
+ ## [12.1.0] - 2026-03-21
6
+ - Replace internal `add_command` method with Selnium Bridge's `add_command` to simplify the codebase.
7
+
5
8
  ## [12.0.1] - 2026-03-07
6
9
  - Improve Steep
7
10
 
data/Gemfile CHANGED
@@ -8,7 +8,7 @@ gem 'minitest', '~> 5.0'
8
8
  gem 'minitest-reporters', '~> 1.1'
9
9
  gem 'parallel_tests'
10
10
  gem 'rake', '~> 13.0'
11
- gem 'rubocop', '1.85.0'
11
+ gem 'rubocop', '1.85.1'
12
12
  gem 'simplecov'
13
13
  gem 'steep', '~> 1.10.0'
14
14
  gem 'webmock', '~> 3.26.0'
@@ -47,8 +47,6 @@ module Appium
47
47
  # No 'browserName' means the session is native appium connection
48
48
  APPIUM_NATIVE_BROWSER_NAME = 'appium'
49
49
 
50
- attr_reader :available_commands
51
-
52
50
  def browser
53
51
  @browser ||= begin
54
52
  name = @capabilities&.browser_name
@@ -74,7 +72,6 @@ module Appium
74
72
  # )
75
73
  #
76
74
  def attach_to(session_id, platform_name, automation_name)
77
- @available_commands = ::Appium::Core::Commands::COMMANDS.dup
78
75
  @session_id = session_id
79
76
 
80
77
  # generate a dummy capabilities instance which only has the given platformName and automationName
@@ -109,8 +106,6 @@ module Appium
109
106
  # driver = core.start_driver
110
107
  #
111
108
  def create_session(capabilities)
112
- @available_commands = ::Appium::Core::Commands::COMMANDS.dup
113
-
114
109
  always_match = add_appium_prefix(capabilities)
115
110
  response = execute(:new_session, {}, { capabilities: { alwaysMatch: always_match, firstMatch: [{}] } }) # steep:ignore
116
111
 
@@ -162,29 +157,16 @@ module Appium
162
157
 
163
158
  public
164
159
 
165
- # command for Appium 2.0.
166
-
167
- # Example:
168
- # driver.add_command(name: :available_contexts, method: :get, url: 'session/:session_id/contexts') do
169
- # execute(:available_contexts, {}) || []
170
- # end
171
- # Then,
172
- # driver.available_contexts #=> ["NATIVE_APP"]
173
-
174
- # def add_command(method:, url:, name:, &block)
175
- # Bridge.add_command name, method, url, &block
176
- # end
177
-
178
- def add_command(method:, url:, name:, &block)
179
- ::Appium::Logger.info "Overriding the method '#{name}' for '#{url}'" if @available_commands.key? name
180
-
181
- @available_commands[name] = [method, url]
182
-
183
- ::Appium::Core::Device.add_endpoint_method name, &block
160
+ # Override Selenium's command_list to use Appium's command definitions
161
+ # instead of the default W3C COMMANDS from Selenium.
162
+ def command_list
163
+ ::Appium::Core::Commands::COMMANDS
184
164
  end
185
165
 
166
+ # Override Selenium's commands to resolve extra_commands from this subclass
167
+ # rather than the parent Selenium::WebDriver::Remote::Bridge.
186
168
  def commands(command)
187
- @available_commands[command] || Bridge.extra_commands[command]
169
+ command_list[command] || self.class.extra_commands&.[](command)
188
170
  end
189
171
 
190
172
  def status
@@ -135,25 +135,21 @@ module Appium
135
135
  # drivers/plugins in Appium 2.0. Appium 2.0 and its custom drivers/plugins allow you
136
136
  # to define custom commands that are not part of W3C spec.
137
137
  #
138
+ # Uses Selenium's +Bridge.add_command+ under the hood to register the command
139
+ # and define the method on the bridge.
140
+ #
138
141
  # @param [Symbol] method HTTP request method as https://www.w3.org/TR/webdriver/#endpoints
139
142
  # @param [string] url The url to URL template as https://www.w3.org/TR/webdriver/#endpoints.
140
143
  # +:session_id+ is the placeholder of 'session id'.
141
144
  # Other place holders can be specified with +:+ prefix like +:id+.
142
145
  # Then, the +:id+ will be replaced with a given value as the seconds argument of +execute+
143
146
  # @param [Symbol] name The name of method that is called as the driver instance method.
144
- # @param [Proc] block The block to involve as the method.
145
- # Please define a method that has the same +name+ with arguments you want.
146
- # The method must has +execute+ method. tHe +execute+ is calls the +url+
147
- # with the given parameters.
148
- # The first argument should be +name+ as symbol.
149
- # The second argument should be hash. If keys in the hash matches +:+ prefix
150
- # string in the given url, the matched string in the given url will be
151
- # values in the hash.
152
- # The third argument should be hash. The hash will be the request body.
153
- # Please read examples below for more details.
147
+ # @param [Proc] block The block becomes the method body. It is executed in the context of
148
+ # the bridge instance, so +execute+ is available. When no block is given,
149
+ # a default implementation calling +execute(name)+ is used.
154
150
  # @raise [ArgumentError] If the given +method+ is invalid value.
155
151
  #
156
- # @example
152
+ # @example Simple GET command (no block)
157
153
  #
158
154
  # @driver.add_command(
159
155
  # method: :get,
@@ -163,30 +159,37 @@ module Appium
163
159
  # # Send a GET request to 'session/<session id>/path/to/custom/url'
164
160
  # @driver.test_command
165
161
  #
162
+ # @example POST command with arguments (do/end block)
166
163
  #
167
164
  # @driver.add_command(
168
165
  # method: :post,
169
166
  # url: 'session/:session_id/path/to/custom/url',
170
167
  # name: :test_command
171
- # ) do
172
- # def test_command(argument)
173
- # execute(:test_command, {}, { dummy: argument })
174
- # end
168
+ # ) do |argument|
169
+ # execute(:test_command, {}, { dummy: argument })
175
170
  # end
176
171
  # # Send a POST request to 'session/<session id>/path/to/custom/url'
177
172
  # # with body "{ dummy: 1 }" as JSON object. "1" is the argument.
178
173
  # # ':session_id' in the given 'url' is replaced with current 'session id'.
179
174
  # @driver.test_command(1)
180
175
  #
176
+ # @example POST command with arguments (inline block)
177
+ #
178
+ # @driver.add_command(
179
+ # method: :post,
180
+ # url: 'session/:session_id/path/to/custom/url',
181
+ # name: :test_command
182
+ # ) { |argument| execute(:test_command, {}, { dummy: argument }) }
183
+ # @driver.test_command(1)
184
+ #
185
+ # @example POST command with URL placeholders (do/end block)
181
186
  #
182
187
  # @driver.add_command(
183
188
  # method: :post,
184
189
  # url: 'session/:session_id/element/:id/custom/action',
185
190
  # name: :test_action_command
186
- # ) do
187
- # def test_action_command(element_id, action)
188
- # execute(:test_action_command, {id: element_id}, { dummy_action: action })
189
- # end
191
+ # ) do |element_id, action|
192
+ # execute(:test_action_command, {id: element_id}, { dummy_action: action })
190
193
  # end
191
194
  # # Send a POST request to 'session/<session id>/element/<element id>/custom/action'
192
195
  # # with body "{ dummy_action: #{action} }" as JSON object. "action" is the seconds argument.
@@ -195,10 +198,28 @@ module Appium
195
198
  # e = @driver.find_element :accessibility_id, 'an element'
196
199
  # @driver.test_action_command(e.id, 'action')
197
200
  #
201
+ # @example POST command with URL placeholders (inline block)
202
+ #
203
+ # @driver.add_command(
204
+ # method: :post,
205
+ # url: 'session/:session_id/element/:id/custom/action',
206
+ # name: :test_action_command
207
+ # ) { |element_id, action| execute(:test_action_command, {id: element_id}, { dummy_action: action }) }
208
+ # e = @driver.find_element :accessibility_id, 'an element'
209
+ # @driver.test_action_command(e.id, 'action')
210
+ #
198
211
  def add_command(method:, url:, name:, &block)
199
212
  raise ::Appium::Core::Error::ArgumentError, "Available method is either #{AVAILABLE_METHODS}" unless AVAILABLE_METHODS.include? method
200
213
 
201
- @bridge.add_command method: method, url: url, name: name, &block
214
+ ::Appium::Logger.info "Overriding the command '#{name}' for '#{url}'" if Bridge.extra_commands&.key?(name)
215
+
216
+ # Use Selenium's Bridge.add_command to register the command and define the method.
217
+ # When no block is given, create a default implementation that calls execute.
218
+ block ||= proc { execute(name) }
219
+ Bridge.add_command(name, method, url, &block)
220
+
221
+ # Ensure the driver delegates the new method to bridge
222
+ self.class.class_eval { def_delegator :@bridge, name } unless self.class.method_defined?(name)
202
223
  end
203
224
 
204
225
  ### Methods for Appium
@@ -14,7 +14,7 @@
14
14
 
15
15
  module Appium
16
16
  module Core
17
- VERSION = '12.0.1' unless defined? ::Appium::Core::VERSION
18
- DATE = '2026-03-07' unless defined? ::Appium::Core::DATE
17
+ VERSION = '12.1.0' unless defined? ::Appium::Core::VERSION
18
+ DATE = '2026-03-21' unless defined? ::Appium::Core::DATE
19
19
  end
20
20
  end
@@ -10,8 +10,6 @@ module Appium
10
10
 
11
11
  @browser: untyped
12
12
 
13
- @available_commands: untyped
14
-
15
13
  @session_id: untyped
16
14
 
17
15
  # generate a dummy capabilities instance which only has the given platformName and automationName
@@ -51,8 +49,6 @@ module Appium
51
49
  # No 'browserName' means the session is native appium connection
52
50
  APPIUM_NATIVE_BROWSER_NAME: "appium"
53
51
 
54
- attr_reader available_commands: untyped
55
-
56
52
  def browser: () -> untyped
57
53
 
58
54
  # Appium only.
@@ -115,8 +111,10 @@ module Appium
115
111
 
116
112
  public
117
113
 
118
- def add_command: (method: untyped, url: untyped, name: untyped) { (?) -> untyped } -> untyped
114
+ # Override Selenium's command_list to use Appium's command definitions
115
+ def command_list: () -> Hash[Symbol, Array[Symbol | String]]
119
116
 
117
+ # Override Selenium's commands to resolve extra_commands from this subclass
120
118
  def commands: (untyped command) -> untyped
121
119
 
122
120
  def status: () -> untyped
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: 12.0.1
4
+ version: 12.1.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: 2026-03-08 00:00:00.000000000 Z
11
+ date: 2026-03-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: selenium-webdriver