From fc05f3a89ef5960448f909627118541868513563 Mon Sep 17 00:00:00 2001 From: titusfortner Date: Fri, 24 Sep 2021 00:11:12 -0500 Subject: [PATCH] [py] implement chromium specific endpoint for setting permissions --- .../webdriver/chromium/remote_connection.py | 1 + py/selenium/webdriver/chromium/webdriver.py | 14 ++++++++++++++ 2 files changed, 15 insertions(+) diff --git a/py/selenium/webdriver/chromium/remote_connection.py b/py/selenium/webdriver/chromium/remote_connection.py index cf143e43785fa..2f56bcf6ee771 100644 --- a/py/selenium/webdriver/chromium/remote_connection.py +++ b/py/selenium/webdriver/chromium/remote_connection.py @@ -23,6 +23,7 @@ def __init__(self, remote_server_addr, vendor_prefix, browser_name, keep_alive=T RemoteConnection.__init__(self, remote_server_addr, keep_alive, ignore_proxy=ignore_proxy) 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') diff --git a/py/selenium/webdriver/chromium/webdriver.py b/py/selenium/webdriver/chromium/webdriver.py index 6d36d4a63d0a9..a171b6438a516 100644 --- a/py/selenium/webdriver/chromium/webdriver.py +++ b/py/selenium/webdriver/chromium/webdriver.py @@ -145,6 +145,20 @@ def delete_network_conditions(self) -> NoReturn: """ self.execute("deleteNetworkConditions") + def set_permissions(self, name: str, value: str) -> NoReturn: + """ + Sets Applicable Permission. + + :Args: + - name: The item to set the permission on. + - value: The value to set on the item + + :Usage: + :: + driver.set_permissions('clipboard-read', 'denied') + """ + self.execute("setPermissions", {'descriptor': {'name': name}, 'state': value}) + def execute_cdp_cmd(self, cmd: str, cmd_args: dict): """ Execute Chrome Devtools Protocol command and get returned result