Skip to content

Commit

Permalink
[py] implement chromium specific endpoint for deleting network condit…
Browse files Browse the repository at this point in the history
…ions
  • Loading branch information
titusfortner committed Sep 24, 2021
1 parent 9d55d47 commit 73d6bea
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions py/selenium/webdriver/chromium/remote_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ def __init__(self, remote_server_addr, vendor_prefix, browser_name, keep_alive=T
self._commands["launchApp"] = ('POST', '/session/$sessionId/chromium/launch_app')
self._commands["setNetworkConditions"] = ('POST', '/session/$sessionId/chromium/network_conditions')
self._commands["getNetworkConditions"] = ('GET', '/session/$sessionId/chromium/network_conditions')
self._commands["deleteNetworkConditions"] = ('DELETE', '/session/$sessionId/chromium/network_conditions')
self._commands['executeCdpCommand'] = ('POST', '/session/$sessionId/{}/cdp/execute'.format(vendor_prefix))
self._commands['getSinks'] = ('GET', '/session/$sessionId/{}/cast/get_sinks'.format(vendor_prefix))
self._commands['getIssueMessage'] = ('GET', '/session/$sessionId/{}/cast/get_issue_message'.format(vendor_prefix))
Expand Down
6 changes: 6 additions & 0 deletions py/selenium/webdriver/chromium/webdriver.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,12 @@ def set_network_conditions(self, **network_conditions) -> NoReturn:
'network_conditions': network_conditions
})

def delete_network_conditions(self) -> NoReturn:
"""
Resets Chromium network emulation settings.
"""
self.execute("deleteNetworkConditions")

def execute_cdp_cmd(self, cmd: str, cmd_args: dict):
"""
Execute Chrome Devtools Protocol command and get returned result
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
import pytest

from selenium.common.exceptions import WebDriverException
from selenium.webdriver import Chrome


Expand All @@ -29,3 +31,6 @@ def test_network_conditions_emulation():
assert conditions['latency'] == 56
assert conditions['download_throughput'] == 789
assert conditions['upload_throughput'] == 789
driver.delete_network_conditions()
with pytest.raises(WebDriverException):
driver.get_network_conditions()

0 comments on commit 73d6bea

Please sign in to comment.