Skip to content

Commit

Permalink
[rb] implement endpoint for deleting network conditions
Browse files Browse the repository at this point in the history
  • Loading branch information
titusfortner committed Sep 24, 2021
1 parent 20b5cdb commit 5eaa6e4
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
5 changes: 5 additions & 0 deletions rb/lib/selenium/webdriver/chrome/features.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ module Features
stop_casting: [:post, 'session/:session_id/goog/cast/stop_casting'],
get_network_conditions: [:get, 'session/:session_id/chromium/network_conditions'],
set_network_conditions: [:post, 'session/:session_id/chromium/network_conditions'],
delete_network_conditions: [:delete, 'session/:session_id/chromium/network_conditions'],
send_command: [:post, 'session/:session_id/goog/cdp/execute'],
get_available_log_types: [:get, 'session/:session_id/se/log/types'],
get_log: [:post, 'session/:session_id/se/log']
Expand Down Expand Up @@ -72,6 +73,10 @@ def network_conditions=(conditions)
execute :set_network_conditions, {}, {network_conditions: conditions}
end

def delete_network_conditions
execute :delete_network_conditions
end

def send_command(command_params)
execute :send_command, {}, command_params
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,14 @@ def network_conditions=(conditions)
@bridge.network_conditions = conditions
end

#
# Resets Chromium network emulation settings.
#

def delete_network_conditions
@bridge.delete_network_conditions
end

end # HasNetworkConditions
end # DriverExtensions
end # WebDriver
Expand Down
13 changes: 13 additions & 0 deletions rb/spec/integration/selenium/webdriver/chrome/driver_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,19 @@ module Chrome
end
end

it 'manages network features' do
driver.network_conditions = {offline: false, latency: 56, download_throughput: 789, upload_throughput: 600}
conditions = driver.network_conditions
expect(conditions['offline']).to eq false
expect(conditions['latency']).to eq 56
expect(conditions['download_throughput']).to eq 789
expect(conditions['upload_throughput']).to eq 600
driver.delete_network_conditions

error = /network conditions must be set before it can be retrieved/
expect { driver.network_conditions }.to raise_error(Error::UnknownError, error)
end

# This requires cast sinks to run
it 'casts' do
# Does not get list correctly the first time for some reason
Expand Down

0 comments on commit 5eaa6e4

Please sign in to comment.