Skip to content

Commit 04f9e9f

Browse files
aguspepujagani
andauthored
[rb][BiDi] Add set cache behaviour (#15114)
* Add response handler * Update auth handlers and improve the :on method * Request and response working as expected * Add test for continue without auth and cancel auth * Finish implementation * Correct rubocop offenses * Add alias for user to do network.bidi instead of network.network * Fix rust file causing formatting error * Handle requests and responses in block * Add ability to pass handlers to each different intercepted element * Headers working * All tests passing and signatures simplified * remove unnecessary changes * remove unnecessary changes * Added credentials and set cookie header to intercepted response * Fix rubocop issues * Make auth handler more user friendly * Add filtering an url pattern support * Fix formatting issues * Modify tests to avoid element related failures on firefox * Fix styling of comments * Improve types and hash consistency * Update all the places that use 9.4.8.0 * Serialize request values * Refactor cookies, headers and set cookie headers * Simplify serialization * Add extra type support * Improve typing * transform serialize to as_json * Simplify cookies and add extra unit tests * Simplify cookies and add extra unit tests * add set cache behaviour method for network bidi --------- Co-authored-by: Puja Jagani <[email protected]>
1 parent 3c87e6b commit 04f9e9f

File tree

3 files changed

+23
-0
lines changed

3 files changed

+23
-0
lines changed

rb/lib/selenium/webdriver/bidi/network.rb

+4
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,10 @@ def provide_response(**args)
124124
)
125125
end
126126

127+
def set_cache_behavior(behavior, *contexts)
128+
@bidi.send_cmd('network.setCacheBehavior', cacheBehavior: behavior, contexts: contexts)
129+
end
130+
127131
def on(event, &)
128132
event = EVENTS[event] if event.is_a?(Symbol)
129133
@bidi.add_callback(event, &)

rb/sig/lib/selenium/webdriver/bidi/network.rbs

+2
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ module Selenium
2828

2929
def provide_response: -> Hash[nil, nil]
3030

31+
def set_cache_behavior: (String behavior, Array[BrowsingContext]) -> Hash[nil, nil]
32+
3133
def on: (Symbol event) { (?) -> untyped } -> Hash[nil, nil]
3234
end
3335
end

rb/spec/integration/selenium/webdriver/bidi/network_spec.rb

+17
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,23 @@ class BiDi
176176
expect(source).to include('Hello World!')
177177
end
178178
end
179+
180+
it 'sets the cache to bypass' do
181+
reset_driver!(web_socket_url: true) do |driver|
182+
browsing_context = BrowsingContext.new(driver).create
183+
network = described_class.new(driver.bidi)
184+
network.set_cache_behavior('bypass', browsing_context)
185+
expect(network.set_cache_behavior('bypass', browsing_context)).to be_a(Hash)
186+
end
187+
end
188+
189+
it 'sets the cache to default' do
190+
reset_driver!(web_socket_url: true) do |driver|
191+
browsing_context = BrowsingContext.new(driver).create
192+
network = described_class.new(driver.bidi)
193+
expect(network.set_cache_behavior('default', browsing_context)).to be_a(Hash)
194+
end
195+
end
179196
end
180197
end
181198
end

0 commit comments

Comments
 (0)