Skip to content

Commit 5148a2c

Browse files
committed
Implement distinction between quit/close in browser automation stuff.
1 parent e575996 commit 5148a2c

4 files changed

Lines changed: 18 additions & 1 deletion

File tree

lib/galaxy/selenium/has_driver.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -608,6 +608,10 @@ def get_screenshot_as_png(self) -> bytes:
608608
"""
609609
return self.driver.get_screenshot_as_png()
610610

611+
def close(self) -> None:
612+
"""Cleanup the current browser tab/page."""
613+
self.driver.close()
614+
611615
def quit(self) -> None:
612616
"""
613617
Clean up and close the driver/browser.

lib/galaxy/selenium/has_driver_protocol.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -524,6 +524,11 @@ def prepend_timeout_message(
524524
...
525525

526526
# Lifecycle management
527+
@abstractmethod
528+
def close(self) -> None:
529+
"""Clean up and close the current page/tab."""
530+
...
531+
527532
@abstractmethod
528533
def quit(self) -> None:
529534
"""

lib/galaxy/selenium/has_driver_proxy.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -457,6 +457,10 @@ def prepend_timeout_message(self, timeout_exception: Exception, message: str) ->
457457
return self._driver_impl.prepend_timeout_message(timeout_exception, message)
458458

459459
# Cleanup
460+
def close(self) -> None:
461+
"""Close the current browser/page."""
462+
self._driver_impl.close()
463+
460464
def quit(self) -> None:
461465
"""Quit the driver and clean up resources."""
462466
self._driver_impl.quit()

lib/galaxy/selenium/has_playwright_driver.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1124,14 +1124,18 @@ def get_screenshot_as_png(self) -> bytes:
11241124
"""
11251125
return self.page.screenshot()
11261126

1127+
def close(self) -> None:
1128+
"""Cleanup the current browser tab/page."""
1129+
self._playwright_resources.browser.close()
1130+
11271131
def quit(self) -> None:
11281132
"""
11291133
Clean up and close the driver/browser.
11301134
11311135
This closes all windows/tabs and releases all system resources.
11321136
The driver cannot be used after calling this method.
11331137
"""
1134-
self._playwright_resources.browser.close()
1138+
self.close()
11351139
self._playwright_resources.playwright.stop()
11361140

11371141

0 commit comments

Comments
 (0)