Skip to content

Add BiDi network examples and documentation for Ruby #2100

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
Aug 18, 2025
4 changes: 2 additions & 2 deletions examples/ruby/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ gem 'rake', '~> 13.0'
gem 'rspec', '~> 3.0'
gem 'rubocop', '~> 1.35'
gem 'rubocop-rspec', '~> 3.0'
gem 'selenium-devtools', '= 0.133.0'
gem 'selenium-webdriver', '= 4.29.1'
gem 'selenium-devtools', '= 0.134.0'
gem 'selenium-webdriver', '= 4.30.0'
5 changes: 2 additions & 3 deletions examples/ruby/spec/actions_api/keys_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
let(:driver) { start_session }
let(:wait) { Selenium::WebDriver::Wait.new(timeout: 2) }

it 'key down' do
it 'key down', except: {platforn: :linux, reason: 'it only fails on the linux pipeline'} do
driver.get 'https://www.selenium.dev/selenium/web/single_text_input.html'
wait.until { driver.find_element(id: 'textInput').attribute('autofocus') }

Expand Down Expand Up @@ -56,8 +56,7 @@
expect(text_field.attribute('value')).to eq 'Selenium!'
end

it 'copy and paste', except: {browser: :chrome,
reason: 'https://bugs.chromium.org/p/chromedriver/issues/detail?id=4264'} do
it 'copy and paste' do
driver.get 'https://www.selenium.dev/selenium/web/single_text_input.html'
wait.until { driver.find_element(id: 'textInput').attribute('autofocus') }

Expand Down
2 changes: 1 addition & 1 deletion examples/ruby/spec/actions_api/mouse_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@
expect(y_coord).to be_within(1).of(center_y + 11)
end

it 'offset from viewport' do
it 'offset from viewport', {platforn: :linux, reason: 'it only fails on the linux pipeline'} do
driver.get 'https://www.selenium.dev/selenium/web/mouse_interaction.html'

driver.action
Expand Down
3 changes: 2 additions & 1 deletion examples/ruby/spec/bidi/logging_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
require 'spec_helper'

RSpec.describe 'Logging' do
RSpec.describe 'Logging', exclusive: {bidi: true, reason: 'only executed when bidi is enabled'},
only: {browser: %i[chrome edge firefox]} do
let(:driver) { start_bidi_session }
let(:wait) { Selenium::WebDriver::Wait.new(timeout: 2) }

Expand Down
13 changes: 13 additions & 0 deletions examples/ruby/spec/bidi/network_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
require 'spec_helper'

RSpec.describe 'Network', exclusive: {bidi: true, reason: 'only executed when bidi is enabled'},
only: {browser: %i[chrome edge firefox]} do
let(:driver) { start_bidi_session }
let(:wait) { Selenium::WebDriver::Wait.new(timeout: 2) }

it 'adds an auth handler', skip: 'Do not execute BiDi test' do
driver.network.add_authentication_handler('test', 'test')
driver.navigate.to url_for('basicAuth')
expect(driver.find_element(tag_name: 'h1').text).to eq('authorized')
end
end
3 changes: 2 additions & 1 deletion examples/ruby/spec/drivers/remote_webdriver_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
require 'spec_helper'
require 'selenium/server'

RSpec.describe 'Remote WebDriver' do
RSpec.describe 'Remote WebDriver', except: {platform: :macosx,
reason: 'it only fail due to the server in the mac pipeline'} do
let(:target_directory) { File.join(Dir.tmpdir, SecureRandom.uuid) }
let(:wait) { Selenium::WebDriver::Wait.new(timeout: 2) }
let(:server) do
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,101 @@ For more details, see [Enabling BiDi]({{< ref "BiDi" >}})

## Authentication Handlers

Authentication handlers enable you to intercept authentication requests that occur during a network interaction.
These handlers are useful for automating scenarios involving authentication prompts, such as Basic Auth or Digest Auth.
They allow you to programmatically provide credentials or modify the authentication flow.

### Add Handler

{{< tabpane text=true >}}
{{< tab header="Java" >}}
{{< /tab >}}
{{< tab header="Python" >}}
{{< /tab >}}
{{< tab header="CSharp" >}}
{{< /tab >}}
{{< tab header="Ruby" >}}
{{< gh-codeblock path="examples/ruby/spec/bidi/network_spec.rb#L7-L11" >}}
{{< /tab >}}
{{< tab header="JavaScript" >}}
{{< /tab >}}
{{< tab header="Kotlin" >}}
{{< /tab >}}
{{< /tabpane >}}

## Request Handlers

Request handlers allow you to intercept and manipulate outgoing network requests before they are sent to the server.
This can be used to modify request headers, change the request body, or block specific requests.
Request handlers are essential for testing and debugging scenarios where you need control over outgoing traffic.

### Add Handler

{{< tabpane text=true >}}
{{< tab header="Java" >}}
{{< /tab >}}
{{< tab header="Python" >}}
{{< /tab >}}
{{< tab header="CSharp" >}}
{{< /tab >}}
{{< tab header="Ruby" >}}
{{< /tab >}}
{{< tab header="JavaScript" >}}
{{< /tab >}}
{{< tab header="Kotlin" >}}
{{< /tab >}}
{{< /tabpane >}}

## Response Handlers

Response handlers enable you to intercept and manipulate incoming responses from the server.
They are particularly useful for testing scenarios involving response data, such as verifying or modifying response headers, status codes, or content before it reaches the browser.

{{< tabpane text=true >}}
{{< tab header="Java" >}}
{{< /tab >}}
{{< tab header="Python" >}}
{{< /tab >}}
{{< tab header="CSharp" >}}
{{< /tab >}}
{{< tab header="Ruby" >}}
{{< /tab >}}
{{< tab header="JavaScript" >}}
{{< /tab >}}
{{< tab header="Kotlin" >}}
{{< /tab >}}
{{< /tabpane >}}

## Remove Handler

{{< tabpane text=true >}}
{{< tab header="Java" >}}
{{< /tab >}}
{{< tab header="Python" >}}
{{< /tab >}}
{{< tab header="CSharp" >}}
{{< /tab >}}
{{< tab header="Ruby" >}}
{{< /tab >}}
{{< tab header="JavaScript" >}}
{{< /tab >}}
{{< tab header="Kotlin" >}}
{{< /tab >}}
{{< /tabpane >}}

## Clear Handlers

{{< tabpane text=true >}}
{{< tab header="Java" >}}
{{< /tab >}}
{{< tab header="Python" >}}
{{< /tab >}}
{{< tab header="CSharp" >}}
{{< /tab >}}
{{< tab header="Ruby" >}}
{{< /tab >}}
{{< tab header="JavaScript" >}}
{{< /tab >}}
{{< tab header="Kotlin" >}}
{{< /tab >}}
{{< /tabpane >}}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ weight: 1
description: >
These features are related to networking, and are made available via a "network" namespace.
aliases: [
"/documentation/ja/webdriver/bidirectional/bidirectional_w3c/network",
"/documentation/en/webdriver/bidirectional/bidirectional_w3c/network",
"/documentation/webdriver/bidirectional/webdriver_bidi/network"
]
---
Expand All @@ -17,6 +17,101 @@ For more details, see [Enabling BiDi]({{< ref "BiDi" >}})

## Authentication Handlers

Authentication handlers enable you to intercept authentication requests that occur during a network interaction.
These handlers are useful for automating scenarios involving authentication prompts, such as Basic Auth or Digest Auth.
They allow you to programmatically provide credentials or modify the authentication flow.

### Add Handler

{{< tabpane text=true >}}
{{< tab header="Java" >}}
{{< /tab >}}
{{< tab header="Python" >}}
{{< /tab >}}
{{< tab header="CSharp" >}}
{{< /tab >}}
{{< tab header="Ruby" >}}
{{< gh-codeblock path="examples/ruby/spec/bidi/network_spec.rb#L7-L11" >}}
{{< /tab >}}
{{< tab header="JavaScript" >}}
{{< /tab >}}
{{< tab header="Kotlin" >}}
{{< /tab >}}
{{< /tabpane >}}

## Request Handlers

Request handlers allow you to intercept and manipulate outgoing network requests before they are sent to the server.
This can be used to modify request headers, change the request body, or block specific requests.
Request handlers are essential for testing and debugging scenarios where you need control over outgoing traffic.

### Add Handler

{{< tabpane text=true >}}
{{< tab header="Java" >}}
{{< /tab >}}
{{< tab header="Python" >}}
{{< /tab >}}
{{< tab header="CSharp" >}}
{{< /tab >}}
{{< tab header="Ruby" >}}
{{< /tab >}}
{{< tab header="JavaScript" >}}
{{< /tab >}}
{{< tab header="Kotlin" >}}
{{< /tab >}}
{{< /tabpane >}}

## Response Handlers

Response handlers enable you to intercept and manipulate incoming responses from the server.
They are particularly useful for testing scenarios involving response data, such as verifying or modifying response headers, status codes, or content before it reaches the browser.

{{< tabpane text=true >}}
{{< tab header="Java" >}}
{{< /tab >}}
{{< tab header="Python" >}}
{{< /tab >}}
{{< tab header="CSharp" >}}
{{< /tab >}}
{{< tab header="Ruby" >}}
{{< /tab >}}
{{< tab header="JavaScript" >}}
{{< /tab >}}
{{< tab header="Kotlin" >}}
{{< /tab >}}
{{< /tabpane >}}

## Remove Handler

{{< tabpane text=true >}}
{{< tab header="Java" >}}
{{< /tab >}}
{{< tab header="Python" >}}
{{< /tab >}}
{{< tab header="CSharp" >}}
{{< /tab >}}
{{< tab header="Ruby" >}}
{{< /tab >}}
{{< tab header="JavaScript" >}}
{{< /tab >}}
{{< tab header="Kotlin" >}}
{{< /tab >}}
{{< /tabpane >}}

## Clear Handlers

{{< tabpane text=true >}}
{{< tab header="Java" >}}
{{< /tab >}}
{{< tab header="Python" >}}
{{< /tab >}}
{{< tab header="CSharp" >}}
{{< /tab >}}
{{< tab header="Ruby" >}}
{{< /tab >}}
{{< tab header="JavaScript" >}}
{{< /tab >}}
{{< tab header="Kotlin" >}}
{{< /tab >}}
{{< /tabpane >}}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ weight: 1
description: >
These features are related to networking, and are made available via a "network" namespace.
aliases: [
"/documentation/pt-br/webdriver/bidirectional/bidirectional_w3c/network",
"/documentation/en/webdriver/bidirectional/bidirectional_w3c/network",
"/documentation/webdriver/bidirectional/webdriver_bidi/network"
]
---
Expand All @@ -17,6 +17,101 @@ For more details, see [Enabling BiDi]({{< ref "BiDi" >}})

## Authentication Handlers

Authentication handlers enable you to intercept authentication requests that occur during a network interaction.
These handlers are useful for automating scenarios involving authentication prompts, such as Basic Auth or Digest Auth.
They allow you to programmatically provide credentials or modify the authentication flow.

### Add Handler

{{< tabpane text=true >}}
{{< tab header="Java" >}}
{{< /tab >}}
{{< tab header="Python" >}}
{{< /tab >}}
{{< tab header="CSharp" >}}
{{< /tab >}}
{{< tab header="Ruby" >}}
{{< gh-codeblock path="examples/ruby/spec/bidi/network_spec.rb#L7-L11" >}}
{{< /tab >}}
{{< tab header="JavaScript" >}}
{{< /tab >}}
{{< tab header="Kotlin" >}}
{{< /tab >}}
{{< /tabpane >}}

## Request Handlers

Request handlers allow you to intercept and manipulate outgoing network requests before they are sent to the server.
This can be used to modify request headers, change the request body, or block specific requests.
Request handlers are essential for testing and debugging scenarios where you need control over outgoing traffic.

### Add Handler

{{< tabpane text=true >}}
{{< tab header="Java" >}}
{{< /tab >}}
{{< tab header="Python" >}}
{{< /tab >}}
{{< tab header="CSharp" >}}
{{< /tab >}}
{{< tab header="Ruby" >}}
{{< /tab >}}
{{< tab header="JavaScript" >}}
{{< /tab >}}
{{< tab header="Kotlin" >}}
{{< /tab >}}
{{< /tabpane >}}

## Response Handlers

Response handlers enable you to intercept and manipulate incoming responses from the server.
They are particularly useful for testing scenarios involving response data, such as verifying or modifying response headers, status codes, or content before it reaches the browser.

{{< tabpane text=true >}}
{{< tab header="Java" >}}
{{< /tab >}}
{{< tab header="Python" >}}
{{< /tab >}}
{{< tab header="CSharp" >}}
{{< /tab >}}
{{< tab header="Ruby" >}}
{{< /tab >}}
{{< tab header="JavaScript" >}}
{{< /tab >}}
{{< tab header="Kotlin" >}}
{{< /tab >}}
{{< /tabpane >}}

## Remove Handler

{{< tabpane text=true >}}
{{< tab header="Java" >}}
{{< /tab >}}
{{< tab header="Python" >}}
{{< /tab >}}
{{< tab header="CSharp" >}}
{{< /tab >}}
{{< tab header="Ruby" >}}
{{< /tab >}}
{{< tab header="JavaScript" >}}
{{< /tab >}}
{{< tab header="Kotlin" >}}
{{< /tab >}}
{{< /tabpane >}}

## Clear Handlers

{{< tabpane text=true >}}
{{< tab header="Java" >}}
{{< /tab >}}
{{< tab header="Python" >}}
{{< /tab >}}
{{< tab header="CSharp" >}}
{{< /tab >}}
{{< tab header="Ruby" >}}
{{< /tab >}}
{{< tab header="JavaScript" >}}
{{< /tab >}}
{{< tab header="Kotlin" >}}
{{< /tab >}}
{{< /tabpane >}}
Loading
Loading