Skip to content

Commit 1727e34

Browse files
committed
Refactor docstrings in EdgeOptions and Service classes for clarity and consistency
1 parent d3af98d commit 1727e34

File tree

2 files changed

+36
-8
lines changed

2 files changed

+36
-8
lines changed

py/selenium/webdriver/edge/options.py

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,20 +23,32 @@ class Options(ChromiumOptions):
2323
KEY = "ms:edgeOptions"
2424

2525
def __init__(self) -> None:
26+
"""Initialize EdgeOptions with default settings."""
2627
super().__init__()
2728
self._use_webview = False
2829

2930
@property
3031
def use_webview(self) -> bool:
32+
"""Returns:
33+
Whether WebView2 is enabled for Edge browser.
34+
"""
3135
return self._use_webview
3236

3337
@use_webview.setter
3438
def use_webview(self, value: bool) -> None:
39+
"""Enables or disables WebView2 support for Edge browser.
40+
41+
Args:
42+
value: True to enable WebView2 support, False to disable.
43+
"""
3544
self._use_webview = bool(value)
3645

3746
def to_capabilities(self) -> dict:
38-
"""Creates a capabilities with all the options that have been set and
39-
:Returns: A dictionary with everything."""
47+
"""Creates a capabilities with all the options that have been set.
48+
49+
Returns:
50+
A dictionary with all set options for Edge browser.
51+
"""
4052
caps = super().to_capabilities()
4153
if self._use_webview:
4254
caps["browserName"] = "webview2"
@@ -45,4 +57,7 @@ def to_capabilities(self) -> dict:
4557

4658
@property
4759
def default_capabilities(self) -> dict:
60+
"""Returns:
61+
The default capabilities for Edge browser.
62+
"""
4863
return DesiredCapabilities.EDGE.copy()

py/selenium/webdriver/edge/service.py

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,13 @@ class Service(service.ChromiumService):
2626
"""A Service class that is responsible for the starting and stopping of
2727
`msedgedriver`.
2828
29-
:param executable_path: install path of the msedgedriver executable, defaults to `msedgedriver`.
30-
:param port: Port for the service to run on, defaults to 0 where the operating system will decide.
31-
:param log_output: (Optional) int representation of STDOUT/DEVNULL, any IO instance or String path to file.
32-
:param service_args: (Optional) Sequence of args to be passed to the subprocess when launching the executable.
33-
:param env: (Optional) Mapping of environment variables for the new process, defaults to `os.environ`.
34-
:param driver_path_env_key: (Optional) Environment variable to use to get the path to the driver executable.
29+
Args:
30+
executable_path: Install path of the msedgedriver executable, defaults to `msedgedriver`.
31+
port: Port for the service to run on, defaults to 0 where the operating system will decide.
32+
log_output: (Optional) int representation of STDOUT/DEVNULL, any IO instance or String path to file.
33+
service_args: (Optional) Sequence of args to be passed to the subprocess when launching the executable.
34+
env: (Optional) Mapping of environment variables for the new process, defaults to `os.environ`.
35+
driver_path_env_key: (Optional) Environment variable to use to get the path to the driver executable.
3536
"""
3637

3738
def __init__(
@@ -44,6 +45,7 @@ def __init__(
4445
driver_path_env_key: Optional[str] = None,
4546
**kwargs,
4647
) -> None:
48+
"""Initialize Edge service with the specified parameters."""
4749
self._service_args = list(service_args or [])
4850
driver_path_env_key = driver_path_env_key or "SE_EDGEDRIVER"
4951

@@ -59,10 +61,21 @@ def __init__(
5961

6062
@property
6163
def service_args(self) -> Sequence[str]:
64+
"""Returns:
65+
The sequence of service arguments.
66+
"""
6267
return self._service_args
6368

6469
@service_args.setter
6570
def service_args(self, value: Sequence[str]):
71+
"""Sets the service arguments for the Edge driver.
72+
73+
Args:
74+
value: A sequence of strings representing service arguments.
75+
76+
Raises:
77+
TypeError: If value is not a sequence or is a string.
78+
"""
6679
if isinstance(value, str) or not isinstance(value, Sequence):
6780
raise TypeError("service_args must be a sequence")
6881
self._service_args = list(value)

0 commit comments

Comments
 (0)