From bee73075b4da873829663bbe50c77821a5440453 Mon Sep 17 00:00:00 2001 From: Augustin Pequeno Date: Sat, 14 Dec 2024 16:17:26 +0100 Subject: [PATCH 1/2] Add BiDi network examples and documentation for Ruby --- examples/ruby/spec/bidi/network_spec.rb | 39 +++++++ .../webdriver/bidi/network.en.md | 99 +++++++++++++++++ .../webdriver/bidi/network.ja.md | 101 +++++++++++++++++- .../webdriver/bidi/network.pt-br.md | 101 +++++++++++++++++- .../webdriver/bidi/network.zh-cn.md | 101 +++++++++++++++++- 5 files changed, 438 insertions(+), 3 deletions(-) create mode 100644 examples/ruby/spec/bidi/network_spec.rb diff --git a/examples/ruby/spec/bidi/network_spec.rb b/examples/ruby/spec/bidi/network_spec.rb new file mode 100644 index 000000000000..630d294a2f9b --- /dev/null +++ b/examples/ruby/spec/bidi/network_spec.rb @@ -0,0 +1,39 @@ +require 'spec_helper' + +RSpec.describe 'Network' do + let(:driver) { start_bidi_session } + let(:wait) { Selenium::WebDriver::Wait.new(timeout: 2) } + + it 'adds an auth handler' do + network = driver.network + network.add_authentication_handler('username', 'password') + expect(network.callbacks.count).to be 1 + end + + it 'adds a request handler' do + network = driver.network + network.add_request_handler + expect(network.callbacks.count).to be 1 + end + + it 'adds a response handler' do + network = driver.network + network.add_response_handler + expect(network.callbacks.count).to be 1 + end + + it 'removes a handler' do + network = driver.network + id = network.add_request_handler + network.remove_handler(id) + expect(network.callbacks.count).to be 0 + end + + it 'clears all handlers' do + network = driver.network + network.add_request_handler + network.add_request_handler + network.clear_handlers + expect(network.callbacks.count).to be 0 + end +end diff --git a/website_and_docs/content/documentation/webdriver/bidi/network.en.md b/website_and_docs/content/documentation/webdriver/bidi/network.en.md index 989ec39ca556..a420c6765866 100644 --- a/website_and_docs/content/documentation/webdriver/bidi/network.en.md +++ b/website_and_docs/content/documentation/webdriver/bidi/network.en.md @@ -17,6 +17,105 @@ 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#L8-L10" >}} +{{< /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" >}} +{{< gh-codeblock path="examples/ruby/spec/bidi/network_spec.rb#L14-L16" >}} +{{< /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" >}} +{{< gh-codeblock path="examples/ruby/spec/bidi/network_spec.rb#L20-L22" >}} +{{< /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" >}} +{{< gh-codeblock path="examples/ruby/spec/bidi/network_spec.rb#L26-L29" >}} +{{< /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" >}} +{{< gh-codeblock path="examples/ruby/spec/bidi/network_spec.rb#L33-L37" >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< /tab >}} +{{< /tabpane >}} diff --git a/website_and_docs/content/documentation/webdriver/bidi/network.ja.md b/website_and_docs/content/documentation/webdriver/bidi/network.ja.md index da4e2d7eb0ee..677c13e7f994 100644 --- a/website_and_docs/content/documentation/webdriver/bidi/network.ja.md +++ b/website_and_docs/content/documentation/webdriver/bidi/network.ja.md @@ -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" ] --- @@ -17,6 +17,105 @@ 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#L8-L10" >}} +{{< /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" >}} +{{< gh-codeblock path="examples/ruby/spec/bidi/network_spec.rb#L14-L16" >}} +{{< /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" >}} +{{< gh-codeblock path="examples/ruby/spec/bidi/network_spec.rb#L20-L22" >}} +{{< /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" >}} +{{< gh-codeblock path="examples/ruby/spec/bidi/network_spec.rb#L26-L29" >}} +{{< /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" >}} +{{< gh-codeblock path="examples/ruby/spec/bidi/network_spec.rb#L33-L37" >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< /tab >}} +{{< /tabpane >}} diff --git a/website_and_docs/content/documentation/webdriver/bidi/network.pt-br.md b/website_and_docs/content/documentation/webdriver/bidi/network.pt-br.md index 60338930f815..677c13e7f994 100644 --- a/website_and_docs/content/documentation/webdriver/bidi/network.pt-br.md +++ b/website_and_docs/content/documentation/webdriver/bidi/network.pt-br.md @@ -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" ] --- @@ -17,6 +17,105 @@ 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#L8-L10" >}} +{{< /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" >}} +{{< gh-codeblock path="examples/ruby/spec/bidi/network_spec.rb#L14-L16" >}} +{{< /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" >}} +{{< gh-codeblock path="examples/ruby/spec/bidi/network_spec.rb#L20-L22" >}} +{{< /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" >}} +{{< gh-codeblock path="examples/ruby/spec/bidi/network_spec.rb#L26-L29" >}} +{{< /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" >}} +{{< gh-codeblock path="examples/ruby/spec/bidi/network_spec.rb#L33-L37" >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< /tab >}} +{{< /tabpane >}} diff --git a/website_and_docs/content/documentation/webdriver/bidi/network.zh-cn.md b/website_and_docs/content/documentation/webdriver/bidi/network.zh-cn.md index 4b97ed012af8..677c13e7f994 100644 --- a/website_and_docs/content/documentation/webdriver/bidi/network.zh-cn.md +++ b/website_and_docs/content/documentation/webdriver/bidi/network.zh-cn.md @@ -5,7 +5,7 @@ weight: 1 description: > These features are related to networking, and are made available via a "network" namespace. aliases: [ - "/documentation/zh-cn/webdriver/bidirectional/bidirectional_w3c/network", + "/documentation/en/webdriver/bidirectional/bidirectional_w3c/network", "/documentation/webdriver/bidirectional/webdriver_bidi/network" ] --- @@ -17,6 +17,105 @@ 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#L8-L10" >}} +{{< /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" >}} +{{< gh-codeblock path="examples/ruby/spec/bidi/network_spec.rb#L14-L16" >}} +{{< /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" >}} +{{< gh-codeblock path="examples/ruby/spec/bidi/network_spec.rb#L20-L22" >}} +{{< /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" >}} +{{< gh-codeblock path="examples/ruby/spec/bidi/network_spec.rb#L26-L29" >}} +{{< /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" >}} +{{< gh-codeblock path="examples/ruby/spec/bidi/network_spec.rb#L33-L37" >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< /tab >}} +{{< /tabpane >}} From f720c45e1d30a1effbdde0d2bc5f3deccbd205c7 Mon Sep 17 00:00:00 2001 From: Augustin Pequeno Date: Sat, 14 Dec 2024 16:22:14 +0100 Subject: [PATCH 2/2] Add skips until new Selenium release --- examples/ruby/spec/bidi/network_spec.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/examples/ruby/spec/bidi/network_spec.rb b/examples/ruby/spec/bidi/network_spec.rb index 630d294a2f9b..031d6befd1d9 100644 --- a/examples/ruby/spec/bidi/network_spec.rb +++ b/examples/ruby/spec/bidi/network_spec.rb @@ -4,32 +4,32 @@ let(:driver) { start_bidi_session } let(:wait) { Selenium::WebDriver::Wait.new(timeout: 2) } - it 'adds an auth handler' do + it 'adds an auth handler', skip: 'until Selenium release 4.28.0' do network = driver.network network.add_authentication_handler('username', 'password') expect(network.callbacks.count).to be 1 end - it 'adds a request handler' do + it 'adds a request handler', skip: 'until Selenium release 4.28.0' do network = driver.network network.add_request_handler expect(network.callbacks.count).to be 1 end - it 'adds a response handler' do + it 'adds a response handler', skip: 'until Selenium release 4.28.0' do network = driver.network network.add_response_handler expect(network.callbacks.count).to be 1 end - it 'removes a handler' do + it 'removes a handler', skip: 'until Selenium release 4.28.0' do network = driver.network id = network.add_request_handler network.remove_handler(id) expect(network.callbacks.count).to be 0 end - it 'clears all handlers' do + it 'clears all handlers', skip: 'until Selenium release 4.28.0' do network = driver.network network.add_request_handler network.add_request_handler