Skip to content

Commit 9b80833

Browse files
committed
refactor: standardize argument documentation format across multiple modules in webdriwer common
1 parent 4ba3d99 commit 9b80833

File tree

7 files changed

+90
-250
lines changed

7 files changed

+90
-250
lines changed

py/selenium/webdriver/common/alert.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ class Alert:
4747
def __init__(self, driver) -> None:
4848
"""Creates a new Alert.
4949
50-
:Args:
51-
- driver: The WebDriver instance which performs user actions.
50+
Args:
51+
driver: The WebDriver instance which performs user actions.
5252
"""
5353
self.driver = driver
5454

@@ -64,17 +64,15 @@ def dismiss(self) -> None:
6464
def accept(self) -> None:
6565
"""Accepts the alert available.
6666
67-
:Usage:
68-
::
69-
70-
Alert(driver).accept() # Confirm a alert dialog.
67+
Example:
68+
Alert(driver).accept() # Confirm a alert dialog.
7169
"""
7270
self.driver.execute(Command.W3C_ACCEPT_ALERT)
7371

7472
def send_keys(self, keysToSend: str) -> None:
7573
"""Send Keys to the Alert.
7674
77-
:Args:
78-
- keysToSend: The text to be sent to Alert.
75+
Args:
76+
keysToSend: The text to be sent to Alert.
7977
"""
8078
self.driver.execute(Command.W3C_SET_ALERT_VALUE, {"value": keys_to_typing(keysToSend), "text": keysToSend})

py/selenium/webdriver/common/log.py

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,7 @@ def __init__(self, driver, bidi_session) -> None:
5757
async def mutation_events(self) -> AsyncGenerator[dict[str, Any], None]:
5858
"""Listen for mutation events and emit them as they are found.
5959
60-
:Usage:
61-
::
62-
60+
Example:
6361
async with driver.log.mutation_events() as event:
6462
pages.load("dynamic.html")
6563
driver.find_element(By.ID, "reveal").click()
@@ -101,9 +99,7 @@ async def add_js_error_listener(self) -> AsyncGenerator[dict[str, Any], None]:
10199
"""Listen for JS errors and when the contextmanager exits check if
102100
there were JS Errors.
103101
104-
:Usage:
105-
::
106-
102+
Example:
107103
async with driver.log.add_js_error_listener() as error:
108104
driver.find_element(By.ID, "throwing-mouseover").click()
109105
assert bool(error)
@@ -124,12 +120,10 @@ async def add_js_error_listener(self) -> AsyncGenerator[dict[str, Any], None]:
124120
async def add_listener(self, event_type) -> AsyncGenerator[dict[str, Any], None]:
125121
"""Listen for certain events that are passed in.
126122
127-
:Args:
128-
- event_type: The type of event that we want to look at.
129-
130-
:Usage:
131-
::
123+
Args:
124+
event_type: The type of event that we want to look at.
132125
126+
Example:
133127
async with driver.log.add_listener(Console.log) as messages:
134128
driver.execute_script("console.log('I like cheese')")
135129
assert messages["message"] == "I love cheese"

py/selenium/webdriver/common/proxy.py

Lines changed: 16 additions & 137 deletions
Original file line numberDiff line numberDiff line change
@@ -97,161 +97,41 @@ class Proxy:
9797

9898
# create descriptor type objects
9999
auto_detect = _ProxyTypeDescriptor("autodetect", ProxyType.AUTODETECT)
100-
"""Gets and Sets `auto_detect`
101-
102-
Usage:
103-
------
104-
- Get
105-
- `self.auto_detect`
106-
- Set
107-
- `self.auto_detect` = `value`
108-
109-
Parameters:
110-
-----------
111-
`value`: `str`
112-
"""
100+
"""Proxy autodetection setting (boolean)."""
113101

114102
# TODO: Remove ftpProxy in future version and remove deprecation warning
115103
ftp_proxy = _ProxyTypeDescriptor("ftpProxy", ProxyType.MANUAL)
116-
"""Gets and Sets `ftp_proxy`
117-
118-
Usage:
119-
------
120-
- Get
121-
- `self.ftp_proxy`
122-
- Set
123-
- `self.ftp_proxy` = `value`
124-
125-
Parameters:
126-
-----------
127-
`value`: `str`
128-
"""
104+
"""FTP proxy address (deprecated)."""
129105

130106
http_proxy = _ProxyTypeDescriptor("httpProxy", ProxyType.MANUAL)
131-
"""Gets and Sets `http_proxy`
132-
133-
Usage:
134-
------
135-
- Get
136-
- `self.http_proxy`
137-
- Set
138-
- `self.http_proxy` = `value`
139-
140-
Parameters:
141-
-----------
142-
`value`: `str`
143-
"""
107+
"""HTTP proxy address."""
144108

145109
no_proxy = _ProxyTypeDescriptor("noProxy", ProxyType.MANUAL)
146-
"""Gets and Sets `no_proxy`
147-
148-
Usage:
149-
------
150-
- Get
151-
- `self.no_proxy`
152-
- Set
153-
- `self.no_proxy` = `value`
154-
155-
Parameters:
156-
-----------
157-
`value`: `str`
158-
"""
110+
"""Addresses to bypass proxy."""
159111

160112
proxy_autoconfig_url = _ProxyTypeDescriptor("proxyAutoconfigUrl", ProxyType.PAC)
161-
"""Gets and Sets `proxy_autoconfig_url`
162-
163-
Usage:
164-
------
165-
- Get
166-
- `self.proxy_autoconfig_url`
167-
- Set
168-
- `self.proxy_autoconfig_url` = `value`
169-
170-
Parameters:
171-
-----------
172-
`value`: `str`
173-
"""
113+
"""Proxy autoconfiguration URL."""
174114

175115
ssl_proxy = _ProxyTypeDescriptor("sslProxy", ProxyType.MANUAL)
176-
"""Gets and Sets `ssl_proxy`
177-
178-
Usage:
179-
------
180-
- Get
181-
- `self.ssl_proxy`
182-
- Set
183-
- `self.ssl_proxy` = `value`
184-
185-
Parameters:
186-
-----------
187-
`value`: `str`
188-
"""
116+
"""SSL proxy address."""
189117

190118
socks_proxy = _ProxyTypeDescriptor("socksProxy", ProxyType.MANUAL)
191-
"""Gets and Sets `socks_proxy`
192-
193-
Usage:
194-
------
195-
- Get
196-
- `self.sock_proxy`
197-
- Set
198-
- `self.socks_proxy` = `value`
199-
200-
Parameters:
201-
-----------
202-
`value`: `str`
203-
"""
119+
"""SOCKS proxy address."""
204120

205121
socks_username = _ProxyTypeDescriptor("socksUsername", ProxyType.MANUAL)
206-
"""Gets and Sets `socks_password`
207-
208-
Usage:
209-
------
210-
- Get
211-
- `self.socks_password`
212-
- Set
213-
- `self.socks_password` = `value`
214-
215-
Parameters:
216-
-----------
217-
`value`: `str`
218-
"""
122+
"""SOCKS proxy username."""
219123

220124
socks_password = _ProxyTypeDescriptor("socksPassword", ProxyType.MANUAL)
221-
"""Gets and Sets `socks_password`
222-
223-
Usage:
224-
------
225-
- Get
226-
- `self.socks_password`
227-
- Set
228-
- `self.socks_password` = `value`
229-
230-
Parameters:
231-
-----------
232-
`value`: `str`
233-
"""
125+
"""SOCKS proxy password."""
234126

235127
socks_version = _ProxyTypeDescriptor("socksVersion", ProxyType.MANUAL)
236-
"""Gets and Sets `socks_version`
237-
238-
Usage:
239-
------
240-
- Get
241-
- `self.socks_version`
242-
- Set
243-
- `self.socks_version` = `value`
244-
245-
Parameters:
246-
-----------
247-
`value`: `str`
248-
"""
128+
"""SOCKS proxy version."""
249129

250130
def __init__(self, raw=None):
251131
"""Creates a new Proxy.
252132
253-
:Args:
254-
- raw: raw proxy data. If None, default class values are used.
133+
Args:
134+
raw: Raw proxy data. If None, default class values are used.
255135
"""
256136
if raw:
257137
if "proxyType" in raw and raw["proxyType"]:
@@ -293,8 +173,8 @@ def proxy_type(self):
293173
def proxy_type(self, value) -> None:
294174
"""Sets proxy type.
295175
296-
:Args:
297-
- value: The proxy type.
176+
Args:
177+
value: The proxy type.
298178
"""
299179
self._verify_proxy_type_compatibility(value)
300180
self.proxyType = value
@@ -326,12 +206,11 @@ def to_capabilities(self):
326206
proxy_caps[proxy] = attr_value
327207
return proxy_caps
328208

329-
def to_bidi_dict(self):
209+
def to_bidi_dict(self) -> dict:
330210
"""Convert proxy settings to BiDi format.
331211
332212
Returns:
333-
-------
334-
dict: Proxy configuration in BiDi format.
213+
Proxy configuration in BiDi format.
335214
"""
336215
proxy_type = self.proxyType["string"].lower()
337216
result = {"proxyType": proxy_type}

py/selenium/webdriver/common/selenium_manager.py

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,11 @@ class SeleniumManager:
3838
def binary_paths(self, args: list) -> dict:
3939
"""Determines the locations of the requested assets.
4040
41-
:Args:
42-
- args: the commands to send to the selenium manager binary.
43-
:Returns: dictionary of assets and their path
41+
Args:
42+
args: the commands to send to the selenium manager binary.
43+
44+
Returns:
45+
Dictionary of assets and their path.
4446
"""
4547

4648
args = [str(self._get_binary())] + args
@@ -57,9 +59,11 @@ def binary_paths(self, args: list) -> dict:
5759
def _get_binary() -> Path:
5860
"""Determines the path of the correct Selenium Manager binary.
5961
60-
:Returns: The Selenium Manager executable location
62+
Returns:
63+
The Selenium Manager executable location.
6164
62-
:Raises: WebDriverException if the platform is unsupported
65+
Raises:
66+
WebDriverException: If the platform is unsupported.
6367
"""
6468

6569
compiled_path = Path(__file__).parent.joinpath("selenium-manager")
@@ -105,9 +109,11 @@ def _get_binary() -> Path:
105109
def _run(args: list[str]) -> dict:
106110
"""Executes the Selenium Manager Binary.
107111
108-
:Args:
109-
- args: the components of the command being executed.
110-
:Returns: The log string containing the driver location.
112+
Args:
113+
args: the components of the command being executed.
114+
115+
Returns:
116+
The log string containing the driver location.
111117
"""
112118
command = " ".join(args)
113119
logger.debug("Executing process: %s", command)

0 commit comments

Comments
 (0)