add generic in_frame() context manager, refactor frame switching

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
John Chilton
2026-02-12 14:55:55 -05:00
co-authored by Claude Opus 4.6
parent 4775dff706
commit e04841dbf7
3 changed files with 16 additions and 15 deletions
+10 -7
View File
@@ -404,22 +404,25 @@ class NavigatesGalaxy(HasDriverProxy[WaitType]):
self.remove_local_storage(key)
@contextlib.contextmanager
def main_panel(self):
"""Decorator to operate within the context of Galaxy's main frame."""
def in_frame(self, frame_reference: Union[str, int, Any] = "frame"):
"""Context manager to operate within the context of an iframe."""
try:
self.switch_to_main_panel()
self.switch_to_frame(frame_reference)
yield
finally:
self.switch_to_default_content()
@contextlib.contextmanager
def main_panel(self):
"""Decorator to operate within the context of Galaxy's main frame."""
with self.in_frame(GALAXY_MAIN_FRAME_ID):
yield
@contextlib.contextmanager
def visualization_panel(self):
"""Decorator to operate within the context of Galaxy's visualization frame."""
try:
self.switch_to_frame(GALAXY_VISUALIZATION_FRAME_ID)
with self.in_frame(GALAXY_VISUALIZATION_FRAME_ID):
yield
finally:
self.switch_to_default_content()
def api_get(self, endpoint, data=None, raw=False):
data = data or {}
+3 -4
View File
@@ -28,10 +28,9 @@ class TestDataset(SeleniumTestCase):
dataset_display = self.components.dataset_display.container
dataset_display.wait_for_visible()
self.switch_to_frame()
text = self.components.dataset_display.content.wait_for_text()
assert "chr1 4225 19670" in text
self.driver.switch_to.default_content()
with self.in_frame():
text = self.components.dataset_display.content.wait_for_text()
assert "chr1 4225 19670" in text
@selenium_test
@managed_history
@@ -19,10 +19,9 @@ class TestTutorialMode(SeleniumTestCase):
self.screenshot("tutorial_mode_0_1")
# Access inside the frame
self.switch_to_frame("gtn-embed")
self.wait_for_selector_visible("#top-navbar")
self.screenshot("tutorial_mode_0_2")
self.switch_to_default_content()
with self.in_frame("gtn-embed"):
self.wait_for_selector_visible("#top-navbar")
self.screenshot("tutorial_mode_0_2")
def _ensure_tutorial_mode_available(self):
"""Skip a test if the webhook GTN doesn't appear."""