Skip to content

Commit da9e6fb

Browse files
committed
add set cache behaviour method for network bidi
1 parent 0daec6d commit da9e6fb

File tree

3 files changed

+23
-0
lines changed

3 files changed

+23
-0
lines changed

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,10 @@ def continue_response(**args)
112112
)
113113
end
114114

115+
def set_cache_behavior(behavior, *contexts)
116+
@bidi.send_cmd('network.setCacheBehavior', cacheBehavior: behavior, contexts: contexts)
117+
end
118+
115119
def on(event, &)
116120
event = EVENTS[event] if event.is_a?(Symbol)
117121
@bidi.add_callback(event, &)

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ module Selenium
2727
def continue_with_auth: (String request_id, String username, String password) -> Hash[nil, nil]
2828

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

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,23 @@ class BiDi
144144
expect(driver.find_element(name: 'login')).to be_displayed
145145
end
146146
end
147+
148+
it 'sets the cache to bypass' do
149+
reset_driver!(web_socket_url: true) do |driver|
150+
browsing_context = BrowsingContext.new(driver).create
151+
network = described_class.new(driver.bidi)
152+
network.set_cache_behavior('bypass', browsing_context)
153+
expect(network.set_cache_behavior('bypass', browsing_context)).to be_a(Hash)
154+
end
155+
end
156+
157+
it 'sets the cache to default' do
158+
reset_driver!(web_socket_url: true) do |driver|
159+
browsing_context = BrowsingContext.new(driver).create
160+
network = described_class.new(driver.bidi)
161+
expect(network.set_cache_behavior('default', browsing_context)).to be_a(Hash)
162+
end
163+
end
147164
end
148165
end
149166
end

0 commit comments

Comments
 (0)