Skip to content

Commit d3af98d

Browse files
committed
Refactor docstrings in ChromiumDriver for consistency and clarity
1 parent 2b329a9 commit d3af98d

File tree

1 file changed

+53
-54
lines changed

1 file changed

+53
-54
lines changed

py/selenium/webdriver/chromium/webdriver.py

Lines changed: 53 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,12 @@ def __init__(
4040
"""Creates a new WebDriver instance of the ChromiumDriver. Starts the
4141
service and then creates new WebDriver instance of ChromiumDriver.
4242
43-
:Args:
44-
- browser_name - Browser name used when matching capabilities.
45-
- vendor_prefix - Company prefix to apply to vendor-specific WebDriver extension commands.
46-
- options - this takes an instance of ChromiumOptions
47-
- service - Service object for handling the browser driver if you need to pass extra details
48-
- keep_alive - Whether to configure ChromiumRemoteConnection to use HTTP keep-alive.
43+
Args:
44+
browser_name: Browser name used when matching capabilities.
45+
vendor_prefix: Company prefix to apply to vendor-specific WebDriver extension commands.
46+
options: This takes an instance of ChromiumOptions.
47+
service: Service object for handling the browser driver if you need to pass extra details.
48+
keep_alive: Whether to configure ChromiumRemoteConnection to use HTTP keep-alive.
4949
"""
5050

5151
self.service = service if service else ChromiumService()
@@ -76,33 +76,34 @@ def __init__(
7676
self._is_remote = False
7777

7878
def launch_app(self, id):
79-
"""Launches Chromium app specified by id."""
79+
"""Launches Chromium app specified by id.
80+
81+
Args:
82+
id: The id of the Chromium app to launch.
83+
"""
8084
return self.execute("launchApp", {"id": id})
8185

8286
def get_network_conditions(self):
8387
"""Gets Chromium network emulation settings.
8488
85-
:Returns:
86-
A dict.
87-
For example: {'latency': 4, 'download_throughput': 2, 'upload_throughput': 2, 'offline': False}
89+
Returns:
90+
A dict. For example: {'latency': 4, 'download_throughput': 2, 'upload_throughput': 2}
8891
"""
8992
return self.execute("getNetworkConditions")["value"]
9093

9194
def set_network_conditions(self, **network_conditions) -> None:
9295
"""Sets Chromium network emulation settings.
9396
94-
:Args:
95-
- network_conditions: A dict with conditions specification.
96-
97-
:Usage:
98-
::
97+
Args:
98+
**network_conditions: A dict with conditions specification.
9999
100-
driver.set_network_conditions(
101-
offline=False,
102-
latency=5, # additional latency (ms)
103-
download_throughput=500 * 1024, # maximal throughput
104-
upload_throughput=500 * 1024,
105-
) # maximal throughput
100+
Example:
101+
driver.set_network_conditions(
102+
offline=False,
103+
latency=5, # additional latency (ms)
104+
download_throughput=500 * 1024, # maximal throughput
105+
upload_throughput=500 * 1024,
106+
) # maximal throughput
106107
107108
Note: 'throughput' can be used to set both (for download and upload).
108109
"""
@@ -115,14 +116,12 @@ def delete_network_conditions(self) -> None:
115116
def set_permissions(self, name: str, value: str) -> None:
116117
"""Sets Applicable Permission.
117118
118-
:Args:
119-
- name: The item to set the permission on.
120-
- value: The value to set on the item
121-
122-
:Usage:
123-
::
119+
Args:
120+
name: The item to set the permission on.
121+
value: The value to set on the item
124122
125-
driver.set_permissions("clipboard-read", "denied")
123+
Example:
124+
driver.set_permissions("clipboard-read", "denied")
126125
"""
127126
self.execute("setPermissions", {"descriptor": {"name": name}, "state": value})
128127

@@ -132,26 +131,26 @@ def execute_cdp_cmd(self, cmd: str, cmd_args: dict):
132131
domains/commands, refer to link
133132
https://chromedevtools.github.io/devtools-protocol/
134133
135-
:Args:
136-
- cmd: A str, command name
137-
- cmd_args: A dict, command args. empty dict {} if there is no command args
138-
:Usage:
139-
::
134+
Args:
135+
cmd: A str, command name
136+
cmd_args: A dict, command args. empty dict {} if there is no command args
137+
138+
Example:
139+
driver.execute_cdp_cmd('Network.getResponseBody', {'requestId': requestId})
140140
141-
driver.execute_cdp_cmd('Network.getResponseBody', {'requestId': requestId})
142-
:Returns:
141+
Returns:
143142
A dict, empty dict {} if there is no result to return.
144143
For example to getResponseBody:
145144
{'base64Encoded': False, 'body': 'response body string'}
146145
"""
147146
return super().execute_cdp_cmd(cmd, cmd_args)
148147

149148
def get_sinks(self) -> list:
150-
""":Returns: A list of sinks available for Cast."""
149+
"""Returns: A list of sinks available for Cast."""
151150
return self.execute("getSinks")["value"]
152151

153152
def get_issue_message(self):
154-
""":Returns: An error message when there is any issue in a Cast
153+
"""Returns: An error message when there is any issue in a Cast
155154
session."""
156155
return self.execute("getIssueMessage")["value"]
157156

@@ -168,50 +167,47 @@ def log_types(self):
168167
def get_log(self, log_type):
169168
"""Gets the log for a given log type.
170169
171-
Parameters:
172-
-----------
173-
log_type : str
174-
- Type of log that which will be returned
170+
Args:
171+
log_type: Type of log that which will be returned
175172
176173
Example:
177-
--------
178-
>>> driver.get_log("browser")
179-
>>> driver.get_log("driver")
180-
>>> driver.get_log("client")
181-
>>> driver.get_log("server")
174+
>>> driver.get_log("browser")
175+
>>> driver.get_log("driver")
176+
>>> driver.get_log("client")
177+
>>> driver.get_log("server")
182178
"""
183179
return self.execute(Command.GET_LOG, {"type": log_type})["value"]
184180

185181
def set_sink_to_use(self, sink_name: str) -> dict:
186182
"""Sets a specific sink, using its name, as a Cast session receiver
187183
target.
188184
189-
:Args:
190-
- sink_name: Name of the sink to use as the target.
185+
Args:
186+
sink_name: Name of the sink to use as the target.
191187
"""
192188
return self.execute("setSinkToUse", {"sinkName": sink_name})
193189

194190
def start_desktop_mirroring(self, sink_name: str) -> dict:
195191
"""Starts a desktop mirroring session on a specific receiver target.
196192
197-
:Args:
198-
- sink_name: Name of the sink to use as the target.
193+
Args:
194+
sink_name: Name of the sink to use as the target.
199195
"""
200196
return self.execute("startDesktopMirroring", {"sinkName": sink_name})
201197

202198
def start_tab_mirroring(self, sink_name: str) -> dict:
203199
"""Starts a tab mirroring session on a specific receiver target.
204200
205-
:Args:
206-
- sink_name: Name of the sink to use as the target.
201+
Args:
202+
sink_name: Name of the sink to use as the target.
207203
"""
208204
return self.execute("startTabMirroring", {"sinkName": sink_name})
209205

210206
def stop_casting(self, sink_name: str) -> dict:
211207
"""Stops the existing Cast session on a specific receiver target.
212208
213-
:Args:
214-
- sink_name: Name of the sink to stop the Cast session.
209+
Args:
210+
sink_name: Name of the sink to stop the Cast session.
215211
"""
216212
return self.execute("stopCasting", {"sinkName": sink_name})
217213

@@ -226,10 +222,13 @@ def quit(self) -> None:
226222
self.service.stop()
227223

228224
def download_file(self, *args, **kwargs):
225+
"""Download file functionality is not implemented for Chromium driver."""
229226
raise NotImplementedError
230227

231228
def get_downloadable_files(self, *args, **kwargs):
229+
"""Get downloadable files functionality is not implemented for Chromium driver."""
232230
raise NotImplementedError
233231

234232
def delete_downloadable_files(self, *args, **kwargs):
233+
"""Delete downloadable files functionality is not implemented for Chromium driver."""
235234
raise NotImplementedError

0 commit comments

Comments
 (0)