Skip to content

Commit 0b847d1

Browse files
committed
Add docstrings to __repr__, __enter__, and __exit__ methods in WebDriver class for clarity on functionality
1 parent 9708f0d commit 0b847d1

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

py/selenium/webdriver/remote/webdriver.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,9 +271,19 @@ def __init__(
271271
self._devtools = None
272272

273273
def __repr__(self):
274+
"""Return a string representation of the WebDriver object.
275+
276+
Returns:
277+
A string representation showing the module, class name, and session ID.
278+
"""
274279
return f'<{type(self).__module__}.{type(self).__name__} (session="{self.session_id}")>'
275280

276281
def __enter__(self):
282+
"""Enter the context manager.
283+
284+
Returns:
285+
The WebDriver instance for use in the with block.
286+
"""
277287
return self
278288

279289
def __exit__(
@@ -282,6 +292,15 @@ def __exit__(
282292
exc: Optional[BaseException],
283293
traceback: Optional[types.TracebackType],
284294
):
295+
"""Exit the context manager.
296+
297+
Quits the WebDriver session when exiting the with block.
298+
299+
Args:
300+
exc_type: The exception type if an error occurred in the with block.
301+
exc: The exception value if an error occurred in the with block.
302+
traceback: The traceback if an error occurred in the with block.
303+
"""
285304
self.quit()
286305

287306
@contextmanager

0 commit comments

Comments
 (0)