From fb0fc495601c4c3cb406ef38be0be60622f96025 Mon Sep 17 00:00:00 2001 From: John Chilton Date: Mon, 19 Feb 2018 10:53:11 -0500 Subject: [PATCH] Progress on Jupyter Notebook Selenium tests Break big test into two - one of which will occasionally work against usegalaxy.org now. --- test/galaxy_selenium/navigation.yml | 10 ++++ test/selenium_tests/test_jupyter.py | 76 ++++++++++++++++++++--------- 2 files changed, 62 insertions(+), 24 deletions(-) diff --git a/test/galaxy_selenium/navigation.yml b/test/galaxy_selenium/navigation.yml index 7d7aa41a676..fa338d65825 100644 --- a/test/galaxy_selenium/navigation.yml +++ b/test/galaxy_selenium/navigation.yml @@ -269,6 +269,16 @@ published_grids: selectors: search: '#input-free-text-search-filter' +gies: + jupyter: + selectors: + body: 'body.notebook_app' + trusted_notification: '#notification_trusted' + + selectors: + spinner: 'img#spinner' + iframe: 'body iframe[seamless="seamless"]' + charts: selectors: visualize_button: '.ui-portlet .button i.fa-line-chart' # without icon - it waits on other buttons that aren't visible, need more specific class diff --git a/test/selenium_tests/test_jupyter.py b/test/selenium_tests/test_jupyter.py index 14a74c07a34..7a8ee09cfbe 100644 --- a/test/selenium_tests/test_jupyter.py +++ b/test/selenium_tests/test_jupyter.py @@ -16,7 +16,55 @@ class JupyterTestCase(SeleniumTestCase): @flakey @selenium_test @managed_history - def test_jupyter_session(self): + def test_jupyter_launch(self): + self._stage_test_data_and_launch() + with self.main_panel(): + self.components.gies.spinner.wait_for_absent(wait_type=self.wait_types.GIE_SPAWN) + viz_iframe = self.components.gies.iframe.wait_for_visible(wait_type=self.wait_types.GIE_SPAWN) + try: + self.driver.switch_to.frame(viz_iframe) + self.components.gies.jupyter.body.wait_for_visible() + trusted_element = self.components.gies.jupyter.trusted_notification.wait_for_visible() + assert trusted_element.text == "Trusted" + finally: + self.driver.switch_to.default_content() + + @flakey + @selenium_test + @managed_history + def test_jupyter_interaction(self): + self._stage_test_data_and_launch() + with self.main_panel(): + self.components.gies.spinner.wait_for_absent(wait_type=self.wait_types.GIE_SPAWN) + viz_iframe = self.components.gies.iframe.wait_for_visible(wait_type=self.wait_types.GIE_SPAWN) + try: + self.driver.switch_to.frame(viz_iframe) + self.components.gies.jupyter.body.wait_for_visible() + self.wait_for_selector("ul.nav") + li_links = self.driver.find_elements_by_css_selector("ul.nav li.dropdown a.dropdown-toggle") + cell_li = None + found_li_texts = [] + for li_link in li_links: + li_text = li_link.text + found_li_texts.append(li_text) + if li_link.text == "Cell": + cell_li = li_link + break + if cell_li is None: + raise Exception("Failed to find 'Cell' drop down menu, found menu options %s" % found_li_texts) + cell_li.click() + self.wait_for_and_click_selector("ul#cell_menu li#run_all_cells") + finally: + self.driver.switch_to.default_content() + + self.sleep_for(wait_type=self.wait_types.JOB_COMPLETION) + self.history_panel_refresh_click() + + # Re-running notebook should publish two new things to the history. + self.history_panel_wait_for_hid_ok(3) + self.history_panel_wait_for_hid_ok(4) + + def _stage_test_data_and_launch(self): self.perform_upload(self.get_filename("1.txt")) self.perform_upload(self.get_filename("selenium-test-notebook.ipynb")) self.wait_for_history() @@ -24,26 +72,6 @@ class JupyterTestCase(SeleniumTestCase): self.history_panel_item_click_visualization_menu(2) self.ensure_visualization_available(2, JUPYTER_VISUALIZATION_NAME) self.history_panel_item_click_visualization(2, JUPYTER_VISUALIZATION_NAME) - with self.main_panel(): - viz_iframe = self.wait_for_selector("body iframe", wait_type=self.wait_types.GIE_SPAWN) - try: - self.driver.switch_to.frame(viz_iframe) - self.wait_for_selector("ul.nav") - lis = self.driver.find_elements_by_css_selector("ul.nav li.dropdown") - cell_li = None - for li in lis: - if li.text == "Cell": - cell_li = li - break - cell_li.click() - self.wait_for_and_click_selector("ul#cell_menu li#run_all_cells") - finally: - self.driver.switch_to.default_content() - - # TODO: wait on something in the notebook instead of sleeping so long. - self.sleep_for(wait_type=self.wait_types.JOB_COMPLETION) - self.history_panel_refresh_click() - - # Re-running notebook should publish two new things to the history. - self.history_panel_wait_for_hid_ok(3) - self.history_panel_wait_for_hid_ok(4) + # Wait for the link to update the content to main panel, without this sleep I think + # sometimes Selenium is waiting in the previous page (presumably Galaxy's welcome). + self.sleep_for(wait_type=self.wait_types.UX_TRANSITION)