diff --git a/py/selenium/webdriver/chromium/options.py b/py/selenium/webdriver/chromium/options.py index 3203f9b5fb6c9..e7cbc2ec2fe53 100644 --- a/py/selenium/webdriver/chromium/options.py +++ b/py/selenium/webdriver/chromium/options.py @@ -44,8 +44,9 @@ def binary_location(self) -> str: def binary_location(self, value: str) -> None: """Allows you to set where the chromium binary lives. - :Args: - - value: path to the Chromium binary + Parameters: + ---------- + value: path to the Chromium binary """ if not isinstance(value, str): raise TypeError(self.BINARY_LOCATION_ERROR) @@ -61,8 +62,9 @@ def debugger_address(self, value: str) -> None: """Allows you to set the address of the remote devtools instance that the ChromeDriver instance will try to connect to during an active wait. - :Args: - - value: address of remote devtools instance if any (hostname[:port]) + Parameters: + ---------- + value: address of remote devtools instance if any (hostname[:port]) """ if not isinstance(value, str): raise TypeError("Debugger Address must be a string") @@ -89,8 +91,9 @@ def add_extension(self, extension: str) -> None: """Adds the path to the extension to a list that will be used to extract it to the ChromeDriver. - :Args: - - extension: path to the \\*.crx file + Parameters: + ---------- + extension: path to the \\*.crx file """ if extension: extension_to_add = os.path.abspath(os.path.expanduser(extension)) @@ -105,8 +108,9 @@ def add_encoded_extension(self, extension: str) -> None: """Adds Base64 encoded string with extension data to a list that will be used to extract it to the ChromeDriver. - :Args: - - extension: Base64 encoded string with extension data + Parameters: + ---------- + extension: Base64 encoded string with extension data """ if extension: self._extensions.append(extension) @@ -121,7 +125,8 @@ def experimental_options(self) -> dict: def add_experimental_option(self, name: str, value: Union[str, int, dict, list[str]]) -> None: """Adds an experimental option which is passed to chromium. - :Args: + Parameters: + ---------- name: The experimental option name. value: The option value. """ @@ -129,9 +134,8 @@ def add_experimental_option(self, name: str, value: Union[str, int, dict, list[s @property def enable_webextensions(self) -> bool: - """Returns whether webextension support is enabled for Chromium-based browsers. - - :Returns: True if webextension support is enabled, False otherwise. + """:Returns: Whether webextension support is enabled for Chromium-based browsers. + True if webextension support is enabled, False otherwise. """ return self._enable_webextensions @@ -139,12 +143,19 @@ def enable_webextensions(self) -> bool: def enable_webextensions(self, value: bool) -> None: """Enables or disables webextension support for Chromium-based browsers. - When enabled, this automatically adds the required Chromium flags: - - --enable-unsafe-extension-debugging - - --remote-debugging-pipe - - :Args: - - value: True to enable webextension support, False to disable. + Parameters: + ---------- + value : bool + True to enable webextension support, False to disable. + + Notes: + ----- + - When enabled, this automatically adds the required Chromium flags: + - --enable-unsafe-extension-debugging + - --remote-debugging-pipe + - Enabling --remote-debugging-pipe makes the connection b/w chromedriver + and the browser a pipe instead of a port, disabling many CDP functionalities + like devtools """ self._enable_webextensions = value if value: @@ -162,7 +173,11 @@ def enable_webextensions(self, value: bool) -> None: def to_capabilities(self) -> dict: """Creates a capabilities with all the options that have been set - :Returns: A dictionary with everything.""" + + Returns: + ------- + dict : a dictionary with all set options + """ caps = self._caps chrome_options = self.experimental_options.copy() if self.mobile_options: diff --git a/py/selenium/webdriver/remote/webdriver.py b/py/selenium/webdriver/remote/webdriver.py index 62ce619105186..7b19f053f3c99 100644 --- a/py/selenium/webdriver/remote/webdriver.py +++ b/py/selenium/webdriver/remote/webdriver.py @@ -1396,10 +1396,13 @@ def _get_cdp_details(self): import urllib3 http = urllib3.PoolManager() - if self.caps.get("browserName") == "chrome": - debugger_address = self.caps.get("goog:chromeOptions").get("debuggerAddress") - elif self.caps.get("browserName") == "MicrosoftEdge": - debugger_address = self.caps.get("ms:edgeOptions").get("debuggerAddress") + try: + if self.caps.get("browserName") == "chrome": + debugger_address = self.caps.get("goog:chromeOptions").get("debuggerAddress") + elif self.caps.get("browserName") == "MicrosoftEdge": + debugger_address = self.caps.get("ms:edgeOptions").get("debuggerAddress") + except AttributeError: + raise WebDriverException("Can't get debugger address.") res = http.request("GET", f"http://{debugger_address}/json/version") data = json.loads(res.data) diff --git a/py/test/selenium/webdriver/common/bidi_network_tests.py b/py/test/selenium/webdriver/common/bidi_network_tests.py index 5fc168a36503a..3947fa993f561 100644 --- a/py/test/selenium/webdriver/common/bidi_network_tests.py +++ b/py/test/selenium/webdriver/common/bidi_network_tests.py @@ -68,8 +68,6 @@ def callback(request: Request): assert driver.find_element(By.NAME, "login").is_displayed(), "Request not continued" -@pytest.mark.xfail_chrome -@pytest.mark.xfail_edge def test_continue_request(driver, pages): def callback(request: Request): request.continue_request() @@ -80,8 +78,6 @@ def callback(request: Request): assert driver.find_element(By.NAME, "login").is_displayed(), "Request not continued" -@pytest.mark.xfail_chrome -@pytest.mark.xfail_edge def test_continue_with_auth(driver): callback_id = driver.network.add_auth_handler("user", "passwd") assert callback_id is not None, "Request handler not added" @@ -89,8 +85,6 @@ def test_continue_with_auth(driver): assert "authenticated" in driver.page_source, "Authorization failed" -@pytest.mark.xfail_chrome -@pytest.mark.xfail_edge def test_remove_auth_handler(driver): callback_id = driver.network.add_auth_handler("user", "passwd") assert callback_id is not None, "Request handler not added"