Skip to content
Open
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
8c317d8
[build] allow tests tagged exclusive-if-local to run on rbe
titusfortner Mar 22, 2025
bb29c66
merge trunk
aguspe Apr 2, 2025
5b6a0ce
Merge branch 'trunk' of github.com:aguspe/selenium into trunk
aguspe Apr 22, 2025
c9cb77c
Merge branch 'trunk' of github.com:aguspe/selenium into trunk
aguspe Apr 30, 2025
ac9a80e
Merge branch 'trunk' of github.com:aguspe/selenium into trunk
aguspe May 18, 2025
aef922a
Merge branch 'trunk' of github.com:aguspe/selenium into trunk
aguspe May 24, 2025
8dc6cfc
Merge branch 'trunk' of github.com:aguspe/selenium into trunk
aguspe Jun 7, 2025
16dc0d3
Merge branch 'trunk' of github.com:aguspe/selenium into trunk
aguspe Jun 13, 2025
85fdc1c
Merge branch 'trunk' of github.com:aguspe/selenium into trunk
aguspe Jul 14, 2025
72bf4ec
Merge branch 'trunk' of github.com:aguspe/selenium into trunk
aguspe Aug 2, 2025
81f2331
Merge branch 'trunk' of github.com:aguspe/selenium into trunk
aguspe Aug 9, 2025
d03e95b
Merge branch 'trunk' of github.com:aguspe/selenium into trunk
aguspe Aug 19, 2025
0cc0626
Merge branch 'trunk' of github.com:aguspe/selenium into trunk
aguspe Sep 9, 2025
efa60a2
Merge branch 'trunk' of github.com:aguspe/selenium into trunk
aguspe Sep 29, 2025
7de5a08
Merge branch 'trunk' of github.com:aguspe/selenium into trunk
aguspe Sep 30, 2025
629be32
Merge branch 'trunk' of github.com:aguspe/selenium into trunk
aguspe Oct 15, 2025
92be65e
Remove nil values for network requests
aguspe Oct 15, 2025
72445fc
Update intercept request and response and improve headers and cookies
aguspe Oct 16, 2025
247863b
Merge branch 'trunk' into rb_fix_network_issue
diemol Oct 17, 2025
ea1f4f0
request cookie and header setters now take hashes
titusfortner Oct 18, 2025
0f186b9
put the unit tests back
titusfortner Oct 18, 2025
396d55a
All tests fixed
aguspe Oct 18, 2025
0b6d365
Merge remote-tracking branch 'origin/rb_fix_network_issue' into rb_fi…
aguspe Oct 18, 2025
91d1666
Merge branch 'trunk' into rb_fix_network_issue
aguspe Oct 18, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 12 additions & 9 deletions rb/lib/selenium/webdriver/bidi/network.rb
Original file line number Diff line number Diff line change
Expand Up @@ -82,15 +82,16 @@ def cancel_auth(request_id)
end

def continue_request(**args)
@bidi.send_cmd(
'network.continueRequest',
args = {
request: args[:id],
body: args[:body],
cookies: args[:cookies],
headers: args[:headers],
method: args[:method],
url: args[:url]
)
}.compact

@bidi.send_cmd('network.continueRequest', **args)
end

def fail_request(request_id)
Expand All @@ -101,27 +102,29 @@ def fail_request(request_id)
end

def continue_response(**args)
@bidi.send_cmd(
'network.continueResponse',
args = {
request: args[:id],
cookies: args[:cookies],
credentials: args[:credentials],
headers: args[:headers],
reasonPhrase: args[:reason],
statusCode: args[:status]
)
}.compact

@bidi.send_cmd('network.continueResponse', **args)
end

def provide_response(**args)
@bidi.send_cmd(
'network.provideResponse',
args = {
request: args[:id],
body: args[:body],
cookies: args[:cookies],
headers: args[:headers],
reasonPhrase: args[:reason],
statusCode: args[:status]
)
}.compact

@bidi.send_cmd('network.provideResponse', **args)
end

def set_cache_behavior(behavior, *contexts)
Expand Down
123 changes: 123 additions & 0 deletions rb/spec/unit/selenium/webdriver/bidi/network_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
# frozen_string_literal: true

# Licensed to the Software Freedom Conservancy (SFC) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The SFC licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

require File.expand_path('../spec_helper', __dir__)
# Adjust the require path as necessary for your project structure
require File.expand_path('../../../../../lib/selenium/webdriver/bidi/network', __dir__)

module Selenium
module WebDriver
class BiDi
describe Network do
let(:mock_bidi) { instance_double(BiDi, 'Bidi') }
let(:network) { described_class.new(mock_bidi) }
let(:request_id) { '12345-request-id' }

before { allow(mock_bidi).to receive(:send_cmd).and_return({}) }

describe '#continue_request' do
it 'sends only the mandatory request ID when all optional args are nil' do
expected_payload = {request: request_id}

expect(mock_bidi).to have_received(:send_cmd).with('network.continueRequest', expected_payload)

network.continue_request(id: request_id)
end

it 'sends only provided optional args' do
expected_payload = {
request: request_id,
body: {type: 'string', value: 'new body'},
method: 'POST'
}

expect(mock_bidi).to have_received(:send_cmd).with('network.continueRequest', expected_payload)

network.continue_request(
id: request_id,
body: {type: 'string', value: 'new body'},
cookies: nil,
headers: nil,
method: 'POST'
)
end
end

describe '#continue_response' do
it 'sends only the mandatory request ID when all optional args are nil' do
expected_payload = {request: request_id}

expect(mock_bidi).to have_received(:send_cmd).with('network.continueResponse', expected_payload)

network.continue_response(id: request_id)
end

it 'sends only provided optional args' do
expected_headers = [{name: 'Auth', value: {type: 'string', value: 'Token'}}]
expected_payload = {
request: request_id,
headers: expected_headers,
statusCode: 202
}

expect(mock_bidi).to have_received(:send_cmd).with('network.continueResponse', expected_payload)

network.continue_response(
id: request_id,
cookies: nil,
credentials: nil,
headers: expected_headers,
reason: nil,
status: 202
)
end
end

describe '#provide_response' do
it 'sends only the mandatory request ID when all optional args are nil' do
expected_payload = {request: request_id}

expect(mock_bidi).to have_received(:send_cmd).with('network.provideResponse', expected_payload)

network.provide_response(id: request_id)
end

it 'sends only provided optional args' do
expected_payload = {
request: request_id,
body: {type: 'string', value: 'Hello'},
reasonPhrase: 'OK-Custom'
}

expect(mock_bidi).to have_received(:send_cmd).with('network.provideResponse', expected_payload)

network.provide_response(
id: request_id,
body: {type: 'string', value: 'Hello'},
cookies: nil,
headers: nil,
reason: 'OK-Custom',
status: nil
)
end
end
end
end
end
end
Loading