diff --git a/lib/galaxy/selenium/navigates_galaxy.py b/lib/galaxy/selenium/navigates_galaxy.py index 0973f51d371..03def6f1b19 100644 --- a/lib/galaxy/selenium/navigates_galaxy.py +++ b/lib/galaxy/selenium/navigates_galaxy.py @@ -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 {} diff --git a/lib/galaxy_test/selenium/test_dataset.py b/lib/galaxy_test/selenium/test_dataset.py index ba3ff962960..c3582202820 100644 --- a/lib/galaxy_test/selenium/test_dataset.py +++ b/lib/galaxy_test/selenium/test_dataset.py @@ -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 diff --git a/lib/galaxy_test/selenium/test_tutorial_mode.py b/lib/galaxy_test/selenium/test_tutorial_mode.py index 86ada2c5800..6f263ddf4fb 100644 --- a/lib/galaxy_test/selenium/test_tutorial_mode.py +++ b/lib/galaxy_test/selenium/test_tutorial_mode.py @@ -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."""