From af54fde59d4e22aee4196aba312d314cb8764177 Mon Sep 17 00:00:00 2001 From: Oleg Zharkov Date: Mon, 13 Jan 2020 16:15:24 +0100 Subject: [PATCH 1/2] implement workflow bookmark selenium test --- lib/galaxy/selenium/has_driver.py | 8 ++++ .../selenium/test_workflow_editor.py | 37 ++++++++++++++++++- 2 files changed, 44 insertions(+), 1 deletion(-) diff --git a/lib/galaxy/selenium/has_driver.py b/lib/galaxy/selenium/has_driver.py index 0bdf77547a6..6529146c2bf 100644 --- a/lib/galaxy/selenium/has_driver.py +++ b/lib/galaxy/selenium/has_driver.py @@ -106,6 +106,14 @@ class HasDriver(object): ) return element + def wait_for_id_clickable(self, id, **kwds): + element = self._wait_on( + ec.element_to_be_clickable((By.ID, id)), + "ID [%s] to become clickable" % id, + **kwds + ) + return element + def wait_for_clickable(self, selector_template, **kwds): element = self._wait_on( ec.element_to_be_clickable(selector_template.element_locator), diff --git a/lib/galaxy_test/selenium/test_workflow_editor.py b/lib/galaxy_test/selenium/test_workflow_editor.py index c67448f1e57..194ad719d57 100644 --- a/lib/galaxy_test/selenium/test_workflow_editor.py +++ b/lib/galaxy_test/selenium/test_workflow_editor.py @@ -333,6 +333,39 @@ steps: self.assert_modal_has_text("Tool is not installed") self.screenshot("workflow_editor_missing_tool") + @selenium_test + def test_workflow_bookmarking(self): + new_workflow_name = self.workflow_create_new(clear_placeholder=True) + + self.wait_for_id_clickable("workflow-save-button") + + # element is clickable, but still might be behind the modal + self.wait_for_selector_absent_or_hidden(self.modal_body_selector()) + self.driver.find_element_by_id("workflow-save-button").click() + + # wait for saving + self.wait_for_selector_absent_or_hidden(self.modal_body_selector()) + self.driver.find_element_by_id("workflow").click() + + # parse workflow table + table_elements = self.workflow_index_table_elements() + self.sleep_for(self.wait_types.UX_RENDER) + bookmark_td = table_elements[0].find_elements_by_tag_name('td')[3] + + # get bookmark pseudo element + # https://stackoverflow.com/questions/45427223/click-on-pseudo-element-using-selenium + self.action_chains().move_to_element_with_offset(bookmark_td, 20, 20).click().perform() + self.sleep_for(self.wait_types.UX_TRANSITION) + + # search for bookmark in tools menu + tools_search_input = self.driver.find_element_by_name("query") + tools_search_input.send_keys(new_workflow_name) + internal_workflows = self.driver.find_element_by_id("internal-workflows") + worksflows = internal_workflows.find_elements_by_class_name("toolTitle") + + # check if bookmark exists + self.assertTrue(any(workflow.text == new_workflow_name for workflow in worksflows)) + def workflow_editor_maximize_center_pane(self, collapse_left=True, collapse_right=True): if collapse_left: self.components._.left_panel_collapse.wait_for_and_click() @@ -437,7 +470,7 @@ steps: workflow_populator.upload_yaml_workflow(content, name=name) return name - def workflow_create_new(self, annotation=None): + def workflow_create_new(self, annotation=None, clear_placeholder=False): self.workflow_index_open() self.sleep_for(self.wait_types.UX_RENDER) self.click_button_new_workflow() @@ -446,6 +479,8 @@ steps: name = self._get_random_name() annotation = annotation or self._get_random_name() inputs = self.driver.find_elements_by_class_name("ui-input") + if clear_placeholder: + inputs[0].clear() inputs[0].send_keys(name) inputs[1].send_keys(annotation) form_element.click() From 5bf73d739afaf2682742e229343498b01bdc2cb3 Mon Sep 17 00:00:00 2001 From: John Chilton Date: Fri, 17 Jan 2020 13:10:53 -0500 Subject: [PATCH 2/2] Cleanup workflow bookmark test. - Use component abstraction (for atomic retry, establishing an abstract description of interface selectors, etc..) - Augment the test to pre-check the workflow isn't bookmarked initially. - More retry during transitions. --- lib/galaxy/selenium/has_driver.py | 8 ------- lib/galaxy/selenium/navigation.yml | 3 +++ .../selenium/test_workflow_editor.py | 23 +++++++++++-------- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/lib/galaxy/selenium/has_driver.py b/lib/galaxy/selenium/has_driver.py index 6529146c2bf..0bdf77547a6 100644 --- a/lib/galaxy/selenium/has_driver.py +++ b/lib/galaxy/selenium/has_driver.py @@ -106,14 +106,6 @@ class HasDriver(object): ) return element - def wait_for_id_clickable(self, id, **kwds): - element = self._wait_on( - ec.element_to_be_clickable((By.ID, id)), - "ID [%s] to become clickable" % id, - **kwds - ) - return element - def wait_for_clickable(self, selector_template, **kwds): element = self._wait_on( ec.element_to_be_clickable(selector_template.element_locator), diff --git a/lib/galaxy/selenium/navigation.yml b/lib/galaxy/selenium/navigation.yml index 5d5d9a1fcf0..16f0b271b9a 100644 --- a/lib/galaxy/selenium/navigation.yml +++ b/lib/galaxy/selenium/navigation.yml @@ -165,6 +165,8 @@ tool_panel: selectors: tool_link: 'a[href$$="tool_runner?tool_id=${tool_id}"]' outer_tool_link: '.toolTitleNoSection a[href$$="tool_runner?tool_id=${tool_id}"]' + search: '.tool-search-query' + workflow_names: '#internal-workflows .toolTitle' multi_history_view: @@ -252,6 +254,7 @@ workflows: selectors: new_button: '#workflow-create' import_button: '#workflow-import' + save_button: '#workflow-save-button' workflow_run: diff --git a/lib/galaxy_test/selenium/test_workflow_editor.py b/lib/galaxy_test/selenium/test_workflow_editor.py index 194ad719d57..864c295437d 100644 --- a/lib/galaxy_test/selenium/test_workflow_editor.py +++ b/lib/galaxy_test/selenium/test_workflow_editor.py @@ -335,13 +335,23 @@ steps: @selenium_test def test_workflow_bookmarking(self): + @retry_assertion_during_transitions + def assert_workflow_bookmarked_status(target_status): + name_matches = [c.text == new_workflow_name for c in self.components.tool_panel.workflow_names.all()] + status = any(name_matches) + self.assertTrue(status == target_status) + new_workflow_name = self.workflow_create_new(clear_placeholder=True) - self.wait_for_id_clickable("workflow-save-button") + # Assert workflow not initially bookmarked. + assert_workflow_bookmarked_status(False) + + save_button = self.components.workflows.save_button + save_button.wait_for_clickable() # element is clickable, but still might be behind the modal self.wait_for_selector_absent_or_hidden(self.modal_body_selector()) - self.driver.find_element_by_id("workflow-save-button").click() + save_button.wait_for_and_click() # wait for saving self.wait_for_selector_absent_or_hidden(self.modal_body_selector()) @@ -358,13 +368,8 @@ steps: self.sleep_for(self.wait_types.UX_TRANSITION) # search for bookmark in tools menu - tools_search_input = self.driver.find_element_by_name("query") - tools_search_input.send_keys(new_workflow_name) - internal_workflows = self.driver.find_element_by_id("internal-workflows") - worksflows = internal_workflows.find_elements_by_class_name("toolTitle") - - # check if bookmark exists - self.assertTrue(any(workflow.text == new_workflow_name for workflow in worksflows)) + self.components.tool_panel.search.wait_for_and_send_keys(new_workflow_name) + assert_workflow_bookmarked_status(True) def workflow_editor_maximize_center_pane(self, collapse_left=True, collapse_right=True): if collapse_left: