diff --git a/rb/lib/selenium/webdriver/bidi/network.rb b/rb/lib/selenium/webdriver/bidi/network.rb index d3530653445fb..43f9d5ff837e8 100644 --- a/rb/lib/selenium/webdriver/bidi/network.rb +++ b/rb/lib/selenium/webdriver/bidi/network.rb @@ -76,6 +76,31 @@ def cancel_auth(request_id) ) end + def continue_with_request(**args) + response = @bidi.send_cmd( + 'network.continueRequest', + request: args[:request_id], + 'body' => args[:body], + 'cookies' => args[:cookies], + 'headers' => args[:headers], + 'method' => args[:method], + 'url' => args[:url] + ) + response.inspect + end + + def continue_with_response(**args) + @bidi.send_cmd( + 'network.continueResponse', + request: args[:request_id], + 'body' => args[:body], + 'cookies' => args[:cookies], + 'credentials' => args[:credentials], + 'headers' => args[:headers], + 'status' => args[:status] + ) + end + def on(event, &block) event = EVENTS[event] if event.is_a?(Symbol) @bidi.add_callback(event, &block) diff --git a/rb/sig/lib/selenium/webdriver/bidi/network.rbs b/rb/sig/lib/selenium/webdriver/bidi/network.rbs index 7d2524f039fb6..64163bc529aaf 100644 --- a/rb/sig/lib/selenium/webdriver/bidi/network.rbs +++ b/rb/sig/lib/selenium/webdriver/bidi/network.rbs @@ -12,6 +12,10 @@ module Selenium def add_intercept: (?phases: Array[String], ?contexts: BrowsingContext?, ?url_patterns: untyped?) -> Hash[String, String] + def cancel_auth: -> untyped + + def continue_with_auth_no_credentials: -> untyped + def continue_with_request: (**untyped args) -> untyped def continue_with_response: (**untyped args) -> untyped diff --git a/rb/sig/lib/selenium/webdriver/common/network.rbs b/rb/sig/lib/selenium/webdriver/common/network.rbs index 4d89e797a4d3a..8cc204b06c514 100644 --- a/rb/sig/lib/selenium/webdriver/common/network.rbs +++ b/rb/sig/lib/selenium/webdriver/common/network.rbs @@ -7,6 +7,8 @@ module Selenium attr_reader callbacks: Hash[String, String] + attr_reader network: untyped + def initialize: (Remote::Bridge bridge) -> void def add_authentication_handler: (String username, String password) -> String diff --git a/rb/spec/integration/selenium/webdriver/bidi/network_spec.rb b/rb/spec/integration/selenium/webdriver/bidi/network_spec.rb index 446a8e136e5cd..371597a5502bd 100644 --- a/rb/spec/integration/selenium/webdriver/bidi/network_spec.rb +++ b/rb/spec/integration/selenium/webdriver/bidi/network_spec.rb @@ -57,20 +57,16 @@ class BiDi end end - it 'continues with request' do reset_driver!(web_socket_url: true) do |driver| network = described_class.new(driver.bidi) network.add_intercept(phases: [described_class::PHASES[:before_request]]) network.on(:before_request) do |event| - request_id = event['requestId'] - pp 'cheese' + request_id = event['request']['request'] network.continue_with_request(request_id: request_id) end - sleep 2 driver.navigate.to url_for('formPage.html') - sleep 2 expect(driver.find_element(name: 'login')).to be_displayed end end @@ -80,7 +76,7 @@ class BiDi network = described_class.new(driver.bidi) network.add_intercept(phases: [described_class::PHASES[:response_started]]) network.on(:response_started) do |event| - request_id = event['requestId'] + request_id = event['request']['request'] network.continue_with_response(request_id: request_id) end