Skip to content

Commit 068f73b

Browse files
authored
Merge branch 'master' into appium3
2 parents 07a78b1 + 8b3a5af commit 068f73b

15 files changed

Lines changed: 318 additions & 11 deletions

File tree

.github/workflows/functional-test.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,13 @@ jobs:
225225
# - target: test/functional/android/android/mjpeg_server_test.rb,test/functional/android/android/image_comparison_test.rb
226226
# automation_name: espresso
227227
# name: test10
228+
# FIXME: rever the comment out after https://github.com/appium/appium/pull/21468
229+
- target: test/functional/android/webdriver/bidi_test.rb
230+
automation_name: uiautomator2
231+
name: test11
232+
# - target: test/functional/android/webdriver/bidi_test.rb
233+
# automation_name: espresso
234+
# name: test12
228235

229236
env:
230237
API_LEVEL: 36

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22
All notable changes to this project will be documented in this file.
33
Read `release_notes.md` for commit level details.
44

5+
## [11.1.0,11.1.1] - 2025-08-08
6+
- Add WebDriver BiDi support. Please set `webSocketUrl` in the capabilities to enable it.
7+
- `test/functional/android/webdriver/bidi_test.rb` can be an example usage.
8+
- Older versions of the Selenium Ruby bindings may raise exceptions due to missing module dependencies.
9+
510
## [11.0.2] - 2025-04-27
611
- Add more sig definitions [#571](https://github.com/appium/ruby_lib_core/pull/571)
712

Gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ gem 'minitest', '~> 5.0'
88
gem 'minitest-reporters', '~> 1.1'
99
gem 'parallel_tests'
1010
gem 'rake', '~> 13.0'
11-
gem 'rubocop', '1.79.0'
11+
gem 'rubocop', '1.79.2'
1212
gem 'simplecov'
1313
gem 'steep', '~> 1.9.3'
1414
gem 'webmock', '~> 3.25.0'

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ capabilities: {
191191
deviceName: 'iPhone Simulator',
192192
automationName: 'XCUITest',
193193
app: '/path/to/MyiOS.app'
194-
},
194+
}
195195
appium_lib: {
196196
listener: CustomListener.new
197197
}

lib/appium_lib_core/common/base.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,9 @@
3030
require_relative 'device/orientation'
3131

3232
# The following files have selenium-webdriver related stuff.
33-
require_relative 'base/driver'
3433
require_relative 'base/bridge'
34+
require_relative 'base/bidi_bridge'
35+
require_relative 'base/driver'
3536
require_relative 'base/capabilities'
3637
require_relative 'base/http_default'
3738
require_relative 'base/search_context'
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
# frozen_string_literal: true
2+
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
require_relative 'bridge'
16+
17+
module Appium
18+
module Core
19+
class Base
20+
class BiDiBridge < ::Appium::Core::Base::Bridge
21+
attr_reader :bidi
22+
23+
# Override
24+
# Creates session handling.
25+
#
26+
# @param [::Appium::Core::Base::Capabilities, Hash] capabilities A capability
27+
# @return [::Appium::Core::Base::Capabilities]
28+
#
29+
# @example
30+
#
31+
# opts = {
32+
# caps: {
33+
# platformName: :android,
34+
# automationName: 'uiautomator2',
35+
# platformVersion: '15',
36+
# deviceName: 'Android',
37+
# webSocketUrl: true,
38+
# },
39+
# appium_lib: {
40+
# wait: 30
41+
# }
42+
# }
43+
# core = ::Appium::Core.for(caps)
44+
# driver = core.start_driver
45+
#
46+
def create_session(capabilities)
47+
super
48+
49+
return @capabilities if @capabilities.nil?
50+
51+
begin
52+
socket_url = @capabilities[:web_socket_url]
53+
@bidi = ::Selenium::WebDriver::BiDi.new(url: socket_url) if socket_url
54+
rescue StandardError => e
55+
::Appium::Logger.warn "WebSocket connection to #{socket_url} for BiDi failed. Error #{e}"
56+
raise
57+
end
58+
59+
@capabilities
60+
end
61+
62+
def get(url)
63+
browsing_context.navigate(url)
64+
end
65+
66+
def go_back
67+
browsing_context.traverse_history(-1)
68+
end
69+
70+
def go_forward
71+
browsing_context.traverse_history(1)
72+
end
73+
74+
def refresh
75+
browsing_context.reload
76+
end
77+
78+
def quit
79+
super
80+
ensure
81+
bidi.close
82+
end
83+
84+
def close
85+
execute(:close_window).tap { |handles| bidi.close if handles.empty? }
86+
end
87+
88+
private
89+
90+
def browsing_context
91+
@browsing_context ||= ::Selenium::WebDriver::BiDi::BrowsingContext.new(self)
92+
end
93+
end # class BiDiBridge
94+
end # class Base
95+
end # module Core
96+
end # module Appium

lib/appium_lib_core/common/base/driver.rb

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,9 @@ def initialize(bridge: nil, listener: nil, **opts) # rubocop:disable Lint/Missin
5454
@devtools = nil
5555
@bidi = nil
5656

57-
# in the selenium webdriver as well
57+
# internal use
58+
@has_bidi = false
59+
5860
::Selenium::WebDriver::Remote::Bridge.element_class = ::Appium::Core::Element
5961
bridge ||= create_bridge(**opts)
6062
add_extensions(bridge.browser)
@@ -79,7 +81,9 @@ def create_bridge(**opts)
7981

8082
raise ::Appium::Core::Error::ArgumentError, "Unable to create a driver with parameters: #{opts}" unless opts.empty?
8183

82-
bridge = ::Appium::Core::Base::Bridge.new(**bridge_opts)
84+
@has_bidi = capabilities && capabilities['webSocketUrl'] ? true : false
85+
bridge_clzz = @has_bidi ? ::Appium::Core::Base::BiDiBridge : ::Appium::Core::Base::Bridge
86+
bridge = bridge_clzz.new(**bridge_opts)
8387

8488
if session_id.nil?
8589
bridge.create_session(capabilities)
@@ -996,6 +1000,28 @@ def execute_driver(script: '', type: 'webdriverio', timeout_ms: nil)
9961000
def convert_to_element(response_id)
9971001
@bridge.convert_to_element response_id
9981002
end
1003+
1004+
# Return bidi instance
1005+
# @return [::Selenium::WebDriver::BiDi]
1006+
#
1007+
# @example
1008+
#
1009+
# log_entries = []
1010+
# driver.bidi.send_cmd('session.subscribe', 'events': ['log.entryAdded'], 'contexts': ['NATIVE_APP'])
1011+
# subscribe_id = driver.bidi.add_callback('log.entryAdded') do |params|
1012+
# log_entries << params
1013+
# end
1014+
# driver.page_source
1015+
#
1016+
# driver.bidi.remove_callback('log.entryAdded', subscribe_id)
1017+
# driver.bidi.send_cmd('session.unsubscribe', 'events': ['log.entryAdded'], 'contexts': ['NATIVE_APP'])
1018+
#
1019+
def bidi
1020+
return @bridge.bidi if @has_bidi
1021+
1022+
msg = 'BiDi must be enabled by providing webSocketUrl capability to true'
1023+
raise(::Selenium::WebDriver::Error::WebDriverError, msg)
1024+
end
9991025
end # class Driver
10001026
end # class Base
10011027
end # module Core

lib/appium_lib_core/driver.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -421,8 +421,8 @@ def start_driver(server_url: nil,
421421
d_c = DirectConnections.new(@driver.capabilities)
422422
@driver.update_sending_request_to(protocol: d_c.protocol, host: d_c.host, port: d_c.port, path: d_c.path)
423423
end
424-
rescue Errno::ECONNREFUSED
425-
raise "ERROR: Unable to connect to Appium. Is the server running on #{@custom_url}?"
424+
rescue Errno::ECONNREFUSED => e
425+
raise "ERROR: Unable to connect to Appium. Is the server running on #{@custom_url}? Error: #{e}"
426426
end
427427

428428
if @http_client.instance_variable_defined? :@additional_headers

lib/appium_lib_core/version.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
module Appium
1616
module Core
17-
VERSION = '11.0.2' unless defined? ::Appium::Core::VERSION
18-
DATE = '2025-04-27' unless defined? ::Appium::Core::DATE
17+
VERSION = '11.1.1' unless defined? ::Appium::Core::VERSION
18+
DATE = '2025-08-08' unless defined? ::Appium::Core::DATE
1919
end
2020
end

release_notes.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,46 @@
1+
#### v11.1.1 2025-08-08
2+
3+
- [4651cac](https://github.com/appium/ruby_lib_core/commit/4651cac25d4f95374568d1c97083ecd0eb9e4547) Release 11.1.1
4+
- [5b5e47b](https://github.com/appium/ruby_lib_core/commit/5b5e47b05e0f8f2577af4f0d595658531f3efc66) fix: fix rubocop
5+
6+
7+
#### v11.1.0 2025-08-08
8+
9+
- [0486d1b](https://github.com/appium/ruby_lib_core/commit/0486d1b5042ff86c0d4378bbd0eec574d5825fdd) Release 11.1.0
10+
- [fd23456](https://github.com/appium/ruby_lib_core/commit/fd23456861a907adae5d955ca766d70795686465) feat: add BiDi bridge (#631)
11+
- [f244a36](https://github.com/appium/ruby_lib_core/commit/f244a365b067fc925017ca4b1d6fdfd85974221a) chore(deps): update rubocop requirement from 1.79.1 to 1.79.2 (#630)
12+
- [8302f6f](https://github.com/appium/ruby_lib_core/commit/8302f6fd39dfcaf6209b31c3977707305f45af90) docs: fix code example
13+
- [85ffb58](https://github.com/appium/ruby_lib_core/commit/85ffb5831ef35495153532c9e5b65dc55f18c2d1) chore(deps): update rubocop requirement from 1.79.0 to 1.79.1 (#628)
14+
- [1770174](https://github.com/appium/ruby_lib_core/commit/1770174e222f9e68fab5c0f989332a52e004a301) chore(deps): update rubocop requirement from 1.78.0 to 1.79.0 (#627)
15+
- [9e622f2](https://github.com/appium/ruby_lib_core/commit/9e622f220902a9fd71e7b8be5a64f21402cd6422) docs: Update README.md
16+
- [900ff29](https://github.com/appium/ruby_lib_core/commit/900ff29f57d14b0d281a9edcd0270f4ae22bdadc) docs: modify readme a bit
17+
- [65a4e32](https://github.com/appium/ruby_lib_core/commit/65a4e322d80739091c9425d2a5f5bec4ddc290d5) test: fix argument naming in mobile_commands_test.rb
18+
- [2b5a566](https://github.com/appium/ruby_lib_core/commit/2b5a5661d6de87309f874e3f9860ac08c01e5045) test: fix syntax
19+
- [61dfd40](https://github.com/appium/ruby_lib_core/commit/61dfd401a08fb329f5c0cc75b93db93b8cc94779) chore(deps): update rubocop requirement from 1.77.0 to 1.78.0 (#626)
20+
- [1f193c1](https://github.com/appium/ruby_lib_core/commit/1f193c1e2d62722c547089aa1c589ff55cb3d3d7) ci: use prebuilt wda (#625)
21+
- [8c4b08a](https://github.com/appium/ruby_lib_core/commit/8c4b08ad9e4fab7185940393956c14e55dfab9e1) ci: update functional-test.yml
22+
- [ee92823](https://github.com/appium/ruby_lib_core/commit/ee92823e15740df9763ff7970bd8606234689950) test: remove unused variable
23+
- [43c2fd2](https://github.com/appium/ruby_lib_core/commit/43c2fd2b8b8af2d9e4eb4f07e9d74209ace41f88) test: use newer xcode/ios
24+
- [61b2277](https://github.com/appium/ruby_lib_core/commit/61b2277ff2e391571b87e6d3931aac9e0ce9e206) chore(deps): update rubocop requirement from 1.76.2 to 1.77.0 (#624)
25+
- [3de46ab](https://github.com/appium/ruby_lib_core/commit/3de46abaa933e6fa813b78192650e1f9ead5a238) test: tune default caps
26+
- [844a704](https://github.com/appium/ruby_lib_core/commit/844a704935fff3a8e839fed26c649d27ae5d268b) test: tune timeout for uia2 (#623)
27+
- [1d6adc0](https://github.com/appium/ruby_lib_core/commit/1d6adc0b43d5f89b5a5f15315e725ff50a32c804) chore(deps): update rubocop requirement from 1.76.1 to 1.76.2 (#622)
28+
- [b12d61d](https://github.com/appium/ruby_lib_core/commit/b12d61d5837843f4bd53b40a72090e7474a539c4) test: update scenario for ios 26 (#621)
29+
- [8baec17](https://github.com/appium/ruby_lib_core/commit/8baec1754d8af9b1dc0024020ba0c819ea49570a) chore(deps): update rubocop requirement from 1.76.0 to 1.76.1 (#620)
30+
- [cdc82c8](https://github.com/appium/ruby_lib_core/commit/cdc82c8cf165964180a69343ba5294a542e438c8) chore(deps): update rubocop requirement from 1.75.8 to 1.76.0 (#619)
31+
- [7e7166f](https://github.com/appium/ruby_lib_core/commit/7e7166fa76a71ac563813085adf43b86c6221b9f) chore(deps): update rubocop requirement from 1.75.7 to 1.75.8 (#618)
32+
- [82b2180](https://github.com/appium/ruby_lib_core/commit/82b218038d4f7178062127e6ce31de0ac149ceb9) chore(deps): update faye-websocket requirement from ~> 0.11.0 to >= 0.11, < 0.13 (#617)
33+
- [e26e4bb](https://github.com/appium/ruby_lib_core/commit/e26e4bb53573d7bea851ace672beb7f8f3c22cfd) chore(deps): update rubocop requirement from 1.75.6 to 1.75.7 (#616)
34+
- [84341e5](https://github.com/appium/ruby_lib_core/commit/84341e512f777ae602ad57e0ac525cf480e74255) ci: use api level 36 for Android tests (#615)
35+
- [69319c8](https://github.com/appium/ruby_lib_core/commit/69319c8779b076a9827d8c6ec6290292199dee44) ci: turn for win (#612)
36+
- [a28736c](https://github.com/appium/ruby_lib_core/commit/a28736cf63aa41884aff978a0a49001e522c855f) test: some small adjustments
37+
- [1492e6a](https://github.com/appium/ruby_lib_core/commit/1492e6a888f5d2c2151bba2695ff787bee752c0c) test: update the app path
38+
- [019b34a](https://github.com/appium/ruby_lib_core/commit/019b34ad42b0368da21784bffd9acb1012eaba14) chore(deps): update rubocop requirement from 1.75.5 to 1.75.6 (#613)
39+
- [6332ab8](https://github.com/appium/ruby_lib_core/commit/6332ab8392eeabfc8d4905ed3a43ab1305558d52) docs(readme): update Libraries links (#610)
40+
- [985b3b9](https://github.com/appium/ruby_lib_core/commit/985b3b9e92dc537c8816c5a4ec768a6025a3b548) chore(deps): update rubocop requirement from 1.75.4 to 1.75.5 (#609)
41+
- [c5945ca](https://github.com/appium/ruby_lib_core/commit/c5945ca2bc45190a1f36a19154c1cea1b00e6dc1) chore(deps): update rubocop requirement from 1.75.3 to 1.75.4 (#607)
42+
43+
144
#### v11.0.2 2025-04-27
245

346
- [dccd87f](https://github.com/appium/ruby_lib_core/commit/dccd87f9bca10efb541629eb2f0f58bd77fd87fb) Release 11.0.2

0 commit comments

Comments
 (0)