Skip to content

Commit bee7307

Browse files
committed
Add BiDi network examples and documentation for Ruby
1 parent ff1ddd7 commit bee7307

File tree

5 files changed

+438
-3
lines changed

5 files changed

+438
-3
lines changed
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
require 'spec_helper'
2+
3+
RSpec.describe 'Network' do
4+
let(:driver) { start_bidi_session }
5+
let(:wait) { Selenium::WebDriver::Wait.new(timeout: 2) }
6+
7+
it 'adds an auth handler' do
8+
network = driver.network
9+
network.add_authentication_handler('username', 'password')
10+
expect(network.callbacks.count).to be 1
11+
end
12+
13+
it 'adds a request handler' do
14+
network = driver.network
15+
network.add_request_handler
16+
expect(network.callbacks.count).to be 1
17+
end
18+
19+
it 'adds a response handler' do
20+
network = driver.network
21+
network.add_response_handler
22+
expect(network.callbacks.count).to be 1
23+
end
24+
25+
it 'removes a handler' do
26+
network = driver.network
27+
id = network.add_request_handler
28+
network.remove_handler(id)
29+
expect(network.callbacks.count).to be 0
30+
end
31+
32+
it 'clears all handlers' do
33+
network = driver.network
34+
network.add_request_handler
35+
network.add_request_handler
36+
network.clear_handlers
37+
expect(network.callbacks.count).to be 0
38+
end
39+
end

website_and_docs/content/documentation/webdriver/bidi/network.en.md

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,105 @@ For more details, see [Enabling BiDi]({{< ref "BiDi" >}})
1717

1818
## Authentication Handlers
1919

20+
Authentication handlers enable you to intercept authentication requests that occur during a network interaction.
21+
These handlers are useful for automating scenarios involving authentication prompts, such as Basic Auth or Digest Auth.
22+
They allow you to programmatically provide credentials or modify the authentication flow.
23+
24+
### Add Handler
25+
26+
{{< tabpane text=true >}}
27+
{{< tab header="Java" >}}
28+
{{< /tab >}}
29+
{{< tab header="Python" >}}
30+
{{< /tab >}}
31+
{{< tab header="CSharp" >}}
32+
{{< /tab >}}
33+
{{< tab header="Ruby" >}}
34+
{{< gh-codeblock path="examples/ruby/spec/bidi/network_spec.rb#L8-L10" >}}
35+
{{< /tab >}}
36+
{{< tab header="JavaScript" >}}
37+
{{< /tab >}}
38+
{{< tab header="Kotlin" >}}
39+
{{< /tab >}}
40+
{{< /tabpane >}}
41+
2042
## Request Handlers
2143

44+
Request handlers allow you to intercept and manipulate outgoing network requests before they are sent to the server.
45+
This can be used to modify request headers, change the request body, or block specific requests.
46+
Request handlers are essential for testing and debugging scenarios where you need control over outgoing traffic.
47+
48+
### Add Handler
49+
50+
{{< tabpane text=true >}}
51+
{{< tab header="Java" >}}
52+
{{< /tab >}}
53+
{{< tab header="Python" >}}
54+
{{< /tab >}}
55+
{{< tab header="CSharp" >}}
56+
{{< /tab >}}
57+
{{< tab header="Ruby" >}}
58+
{{< gh-codeblock path="examples/ruby/spec/bidi/network_spec.rb#L14-L16" >}}
59+
{{< /tab >}}
60+
{{< tab header="JavaScript" >}}
61+
{{< /tab >}}
62+
{{< tab header="Kotlin" >}}
63+
{{< /tab >}}
64+
{{< /tabpane >}}
65+
2266
## Response Handlers
67+
68+
Response handlers enable you to intercept and manipulate incoming responses from the server.
69+
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.
70+
71+
{{< tabpane text=true >}}
72+
{{< tab header="Java" >}}
73+
{{< /tab >}}
74+
{{< tab header="Python" >}}
75+
{{< /tab >}}
76+
{{< tab header="CSharp" >}}
77+
{{< /tab >}}
78+
{{< tab header="Ruby" >}}
79+
{{< gh-codeblock path="examples/ruby/spec/bidi/network_spec.rb#L20-L22" >}}
80+
{{< /tab >}}
81+
{{< tab header="JavaScript" >}}
82+
{{< /tab >}}
83+
{{< tab header="Kotlin" >}}
84+
{{< /tab >}}
85+
{{< /tabpane >}}
86+
87+
## Remove Handler
88+
89+
{{< tabpane text=true >}}
90+
{{< tab header="Java" >}}
91+
{{< /tab >}}
92+
{{< tab header="Python" >}}
93+
{{< /tab >}}
94+
{{< tab header="CSharp" >}}
95+
{{< /tab >}}
96+
{{< tab header="Ruby" >}}
97+
{{< gh-codeblock path="examples/ruby/spec/bidi/network_spec.rb#L26-L29" >}}
98+
{{< /tab >}}
99+
{{< tab header="JavaScript" >}}
100+
{{< /tab >}}
101+
{{< tab header="Kotlin" >}}
102+
{{< /tab >}}
103+
{{< /tabpane >}}
104+
105+
## Clear Handlers
106+
107+
{{< tabpane text=true >}}
108+
{{< tab header="Java" >}}
109+
{{< /tab >}}
110+
{{< tab header="Python" >}}
111+
{{< /tab >}}
112+
{{< tab header="CSharp" >}}
113+
{{< /tab >}}
114+
{{< tab header="Ruby" >}}
115+
{{< gh-codeblock path="examples/ruby/spec/bidi/network_spec.rb#L33-L37" >}}
116+
{{< /tab >}}
117+
{{< tab header="JavaScript" >}}
118+
{{< /tab >}}
119+
{{< tab header="Kotlin" >}}
120+
{{< /tab >}}
121+
{{< /tabpane >}}

website_and_docs/content/documentation/webdriver/bidi/network.ja.md

Lines changed: 100 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ weight: 1
55
description: >
66
These features are related to networking, and are made available via a "network" namespace.
77
aliases: [
8-
"/documentation/ja/webdriver/bidirectional/bidirectional_w3c/network",
8+
"/documentation/en/webdriver/bidirectional/bidirectional_w3c/network",
99
"/documentation/webdriver/bidirectional/webdriver_bidi/network"
1010
]
1111
---
@@ -17,6 +17,105 @@ For more details, see [Enabling BiDi]({{< ref "BiDi" >}})
1717

1818
## Authentication Handlers
1919

20+
Authentication handlers enable you to intercept authentication requests that occur during a network interaction.
21+
These handlers are useful for automating scenarios involving authentication prompts, such as Basic Auth or Digest Auth.
22+
They allow you to programmatically provide credentials or modify the authentication flow.
23+
24+
### Add Handler
25+
26+
{{< tabpane text=true >}}
27+
{{< tab header="Java" >}}
28+
{{< /tab >}}
29+
{{< tab header="Python" >}}
30+
{{< /tab >}}
31+
{{< tab header="CSharp" >}}
32+
{{< /tab >}}
33+
{{< tab header="Ruby" >}}
34+
{{< gh-codeblock path="examples/ruby/spec/bidi/network_spec.rb#L8-L10" >}}
35+
{{< /tab >}}
36+
{{< tab header="JavaScript" >}}
37+
{{< /tab >}}
38+
{{< tab header="Kotlin" >}}
39+
{{< /tab >}}
40+
{{< /tabpane >}}
41+
2042
## Request Handlers
2143

44+
Request handlers allow you to intercept and manipulate outgoing network requests before they are sent to the server.
45+
This can be used to modify request headers, change the request body, or block specific requests.
46+
Request handlers are essential for testing and debugging scenarios where you need control over outgoing traffic.
47+
48+
### Add Handler
49+
50+
{{< tabpane text=true >}}
51+
{{< tab header="Java" >}}
52+
{{< /tab >}}
53+
{{< tab header="Python" >}}
54+
{{< /tab >}}
55+
{{< tab header="CSharp" >}}
56+
{{< /tab >}}
57+
{{< tab header="Ruby" >}}
58+
{{< gh-codeblock path="examples/ruby/spec/bidi/network_spec.rb#L14-L16" >}}
59+
{{< /tab >}}
60+
{{< tab header="JavaScript" >}}
61+
{{< /tab >}}
62+
{{< tab header="Kotlin" >}}
63+
{{< /tab >}}
64+
{{< /tabpane >}}
65+
2266
## Response Handlers
67+
68+
Response handlers enable you to intercept and manipulate incoming responses from the server.
69+
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.
70+
71+
{{< tabpane text=true >}}
72+
{{< tab header="Java" >}}
73+
{{< /tab >}}
74+
{{< tab header="Python" >}}
75+
{{< /tab >}}
76+
{{< tab header="CSharp" >}}
77+
{{< /tab >}}
78+
{{< tab header="Ruby" >}}
79+
{{< gh-codeblock path="examples/ruby/spec/bidi/network_spec.rb#L20-L22" >}}
80+
{{< /tab >}}
81+
{{< tab header="JavaScript" >}}
82+
{{< /tab >}}
83+
{{< tab header="Kotlin" >}}
84+
{{< /tab >}}
85+
{{< /tabpane >}}
86+
87+
## Remove Handler
88+
89+
{{< tabpane text=true >}}
90+
{{< tab header="Java" >}}
91+
{{< /tab >}}
92+
{{< tab header="Python" >}}
93+
{{< /tab >}}
94+
{{< tab header="CSharp" >}}
95+
{{< /tab >}}
96+
{{< tab header="Ruby" >}}
97+
{{< gh-codeblock path="examples/ruby/spec/bidi/network_spec.rb#L26-L29" >}}
98+
{{< /tab >}}
99+
{{< tab header="JavaScript" >}}
100+
{{< /tab >}}
101+
{{< tab header="Kotlin" >}}
102+
{{< /tab >}}
103+
{{< /tabpane >}}
104+
105+
## Clear Handlers
106+
107+
{{< tabpane text=true >}}
108+
{{< tab header="Java" >}}
109+
{{< /tab >}}
110+
{{< tab header="Python" >}}
111+
{{< /tab >}}
112+
{{< tab header="CSharp" >}}
113+
{{< /tab >}}
114+
{{< tab header="Ruby" >}}
115+
{{< gh-codeblock path="examples/ruby/spec/bidi/network_spec.rb#L33-L37" >}}
116+
{{< /tab >}}
117+
{{< tab header="JavaScript" >}}
118+
{{< /tab >}}
119+
{{< tab header="Kotlin" >}}
120+
{{< /tab >}}
121+
{{< /tabpane >}}

website_and_docs/content/documentation/webdriver/bidi/network.pt-br.md

Lines changed: 100 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ weight: 1
55
description: >
66
These features are related to networking, and are made available via a "network" namespace.
77
aliases: [
8-
"/documentation/pt-br/webdriver/bidirectional/bidirectional_w3c/network",
8+
"/documentation/en/webdriver/bidirectional/bidirectional_w3c/network",
99
"/documentation/webdriver/bidirectional/webdriver_bidi/network"
1010
]
1111
---
@@ -17,6 +17,105 @@ For more details, see [Enabling BiDi]({{< ref "BiDi" >}})
1717

1818
## Authentication Handlers
1919

20+
Authentication handlers enable you to intercept authentication requests that occur during a network interaction.
21+
These handlers are useful for automating scenarios involving authentication prompts, such as Basic Auth or Digest Auth.
22+
They allow you to programmatically provide credentials or modify the authentication flow.
23+
24+
### Add Handler
25+
26+
{{< tabpane text=true >}}
27+
{{< tab header="Java" >}}
28+
{{< /tab >}}
29+
{{< tab header="Python" >}}
30+
{{< /tab >}}
31+
{{< tab header="CSharp" >}}
32+
{{< /tab >}}
33+
{{< tab header="Ruby" >}}
34+
{{< gh-codeblock path="examples/ruby/spec/bidi/network_spec.rb#L8-L10" >}}
35+
{{< /tab >}}
36+
{{< tab header="JavaScript" >}}
37+
{{< /tab >}}
38+
{{< tab header="Kotlin" >}}
39+
{{< /tab >}}
40+
{{< /tabpane >}}
41+
2042
## Request Handlers
2143

44+
Request handlers allow you to intercept and manipulate outgoing network requests before they are sent to the server.
45+
This can be used to modify request headers, change the request body, or block specific requests.
46+
Request handlers are essential for testing and debugging scenarios where you need control over outgoing traffic.
47+
48+
### Add Handler
49+
50+
{{< tabpane text=true >}}
51+
{{< tab header="Java" >}}
52+
{{< /tab >}}
53+
{{< tab header="Python" >}}
54+
{{< /tab >}}
55+
{{< tab header="CSharp" >}}
56+
{{< /tab >}}
57+
{{< tab header="Ruby" >}}
58+
{{< gh-codeblock path="examples/ruby/spec/bidi/network_spec.rb#L14-L16" >}}
59+
{{< /tab >}}
60+
{{< tab header="JavaScript" >}}
61+
{{< /tab >}}
62+
{{< tab header="Kotlin" >}}
63+
{{< /tab >}}
64+
{{< /tabpane >}}
65+
2266
## Response Handlers
67+
68+
Response handlers enable you to intercept and manipulate incoming responses from the server.
69+
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.
70+
71+
{{< tabpane text=true >}}
72+
{{< tab header="Java" >}}
73+
{{< /tab >}}
74+
{{< tab header="Python" >}}
75+
{{< /tab >}}
76+
{{< tab header="CSharp" >}}
77+
{{< /tab >}}
78+
{{< tab header="Ruby" >}}
79+
{{< gh-codeblock path="examples/ruby/spec/bidi/network_spec.rb#L20-L22" >}}
80+
{{< /tab >}}
81+
{{< tab header="JavaScript" >}}
82+
{{< /tab >}}
83+
{{< tab header="Kotlin" >}}
84+
{{< /tab >}}
85+
{{< /tabpane >}}
86+
87+
## Remove Handler
88+
89+
{{< tabpane text=true >}}
90+
{{< tab header="Java" >}}
91+
{{< /tab >}}
92+
{{< tab header="Python" >}}
93+
{{< /tab >}}
94+
{{< tab header="CSharp" >}}
95+
{{< /tab >}}
96+
{{< tab header="Ruby" >}}
97+
{{< gh-codeblock path="examples/ruby/spec/bidi/network_spec.rb#L26-L29" >}}
98+
{{< /tab >}}
99+
{{< tab header="JavaScript" >}}
100+
{{< /tab >}}
101+
{{< tab header="Kotlin" >}}
102+
{{< /tab >}}
103+
{{< /tabpane >}}
104+
105+
## Clear Handlers
106+
107+
{{< tabpane text=true >}}
108+
{{< tab header="Java" >}}
109+
{{< /tab >}}
110+
{{< tab header="Python" >}}
111+
{{< /tab >}}
112+
{{< tab header="CSharp" >}}
113+
{{< /tab >}}
114+
{{< tab header="Ruby" >}}
115+
{{< gh-codeblock path="examples/ruby/spec/bidi/network_spec.rb#L33-L37" >}}
116+
{{< /tab >}}
117+
{{< tab header="JavaScript" >}}
118+
{{< /tab >}}
119+
{{< tab header="Kotlin" >}}
120+
{{< /tab >}}
121+
{{< /tabpane >}}

0 commit comments

Comments
 (0)