Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions py/selenium/webdriver/chromium/remote_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,6 @@ def __init__(
self.browser_name = browser_name
self._commands["launchApp"] = ("POST", "/session/$sessionId/chromium/launch_app")
self._commands["setPermissions"] = ("POST", "/session/$sessionId/permissions")
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", f"/session/$sessionId/{vendor_prefix}/cdp/execute")
self._commands["getSinks"] = ("GET", f"/session/$sessionId/{vendor_prefix}/cast/get_sinks")
self._commands["getIssueMessage"] = ("GET", f"/session/$sessionId/{vendor_prefix}/cast/get_issue_message")
Expand All @@ -45,3 +42,8 @@ def __init__(
)
self._commands["startTabMirroring"] = ("POST", f"/session/$sessionId/{vendor_prefix}/cast/start_tab_mirroring")
self._commands["stopCasting"] = ("POST", f"/session/$sessionId/{vendor_prefix}/cast/stop_casting")

def add_network_commands(self) -> None:
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")
3 changes: 3 additions & 0 deletions py/selenium/webdriver/chromium/webdriver.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@
{'latency': 4, 'download_throughput': 2, 'upload_throughput': 2,
'offline': False}
"""
ChromiumRemoteConnection.add_network_commands(self.command_executor)

Check warning on line 131 in py/selenium/webdriver/chromium/webdriver.py

View check run for this annotation

Codecov / codecov/patch

py/selenium/webdriver/chromium/webdriver.py#L131

Added line #L131 was not covered by tests
return self.execute("getNetworkConditions")["value"]

def set_network_conditions(self, **network_conditions) -> None:
Expand All @@ -147,10 +148,12 @@

Note: 'throughput' can be used to set both (for download and upload).
"""
ChromiumRemoteConnection.add_network_commands(self.command_executor)

Check warning on line 151 in py/selenium/webdriver/chromium/webdriver.py

View check run for this annotation

Codecov / codecov/patch

py/selenium/webdriver/chromium/webdriver.py#L151

Added line #L151 was not covered by tests
self.execute("setNetworkConditions", {"network_conditions": network_conditions})

def delete_network_conditions(self) -> None:
"""Resets Chromium network emulation settings."""
ChromiumRemoteConnection.add_network_commands(self.command_executor)

Check warning on line 156 in py/selenium/webdriver/chromium/webdriver.py

View check run for this annotation

Codecov / codecov/patch

py/selenium/webdriver/chromium/webdriver.py#L156

Added line #L156 was not covered by tests
self.execute("deleteNetworkConditions")

def set_permissions(self, name: str, value: str) -> None:
Expand Down
10 changes: 5 additions & 5 deletions py/selenium/webdriver/firefox/webdriver.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,11 +241,11 @@
... do stuff ...
"""
initial_context = self.execute("GET_CONTEXT").pop("value")
self.set_context(context)
WebDriver.set_context(self, context)

Check warning on line 244 in py/selenium/webdriver/firefox/webdriver.py

View check run for this annotation

Codecov / codecov/patch

py/selenium/webdriver/firefox/webdriver.py#L244

Added line #L244 was not covered by tests
try:
yield
finally:
self.set_context(initial_context)
WebDriver.set_context(self, initial_context)

Check warning on line 248 in py/selenium/webdriver/firefox/webdriver.py

View check run for this annotation

Codecov / codecov/patch

py/selenium/webdriver/firefox/webdriver.py#L248

Added line #L248 was not covered by tests

def install_addon(self, path, temporary=False) -> str:
"""Installs Firefox addon.
Expand Down Expand Up @@ -306,7 +306,7 @@
"name used for saved screenshot does not match file " "type. It should end with a `.png` extension",
UserWarning,
)
png = self.get_full_page_screenshot_as_png()
png = WebDriver.get_full_page_screenshot_as_png(self)
try:
with open(filename, "wb") as f:
f.write(png)
Expand All @@ -330,7 +330,7 @@

driver.save_full_page_screenshot('/Screenshots/foo.png')
"""
return self.get_full_page_screenshot_as_file(filename)
return WebDriver.get_full_page_screenshot_as_file(self, filename)

Check warning on line 333 in py/selenium/webdriver/firefox/webdriver.py

View check run for this annotation

Codecov / codecov/patch

py/selenium/webdriver/firefox/webdriver.py#L333

Added line #L333 was not covered by tests

def get_full_page_screenshot_as_png(self) -> bytes:
"""Gets the full document screenshot of the current window as a binary
Expand All @@ -341,7 +341,7 @@

driver.get_full_page_screenshot_as_png()
"""
return base64.b64decode(self.get_full_page_screenshot_as_base64().encode("ascii"))
return base64.b64decode(WebDriver.get_full_page_screenshot_as_base64(self).encode("ascii"))

def get_full_page_screenshot_as_base64(self) -> str:
"""Gets the full document screenshot of the current window as a base64
Expand Down