diff --git a/lib/galaxy/selenium/navigates_galaxy.py b/lib/galaxy/selenium/navigates_galaxy.py index 5ce7fe10d044..ff1a55ae74c9 100644 --- a/lib/galaxy/selenium/navigates_galaxy.py +++ b/lib/galaxy/selenium/navigates_galaxy.py @@ -559,6 +559,20 @@ def select_grid_operation(self, item_name, option_label): ) popup_option.click() + def select_grid_cell(self, grid_name, item_name, column_index=3): + cell = None + grid = self.wait_for_selector(grid_name) + for row in grid.find_elements(By.TAG_NAME, "tr"): + td = row.find_elements(By.TAG_NAME, "td") + if td[0].text == item_name: + cell = td[column_index] + break + + if cell is None: + raise AssertionError(f"Failed to find cell for item with name [{item_name}]") + + return cell + def published_grid_search_for(self, search_term=None): return self._inline_search_for( self.navigation.grids.free_text_search, diff --git a/lib/galaxy_test/selenium/test_histories_list.py b/lib/galaxy_test/selenium/test_histories_list.py index 5bbacff366c9..affb104206a7 100644 --- a/lib/galaxy_test/selenium/test_histories_list.py +++ b/lib/galaxy_test/selenium/test_histories_list.py @@ -180,17 +180,11 @@ def test_tags(self): self.navigate_to_histories_page() # Insert a tag - tags_cell = self.get_history_tags_cell(self.history2_name) - tag_button = tags_cell.find_element(By.CSS_SELECTOR, ".stateless-tags button") - tag_button.click() - tag_input = tags_cell.find_element(By.CSS_SELECTOR, ".stateless-tags input") - tag_input.send_keys(self.history2_tags[0]) - self.send_enter(tag_input) - self.send_escape(tag_input) - self.sleep_for(self.wait_types.UX_RENDER) + tags_cell = self.select_grid_cell("#histories-grid", self.history2_name, 3) + self.add_tag(tags_cell, self.history2_tags[0]) # Search by tag - tags_cell = self.get_history_tags_cell(self.history2_name) + tags_cell = self.select_grid_cell("#histories-grid", self.history2_name, 3) tag = tags_cell.find_element(By.CSS_SELECTOR, ".tag") tag.click() @@ -220,6 +214,15 @@ def assert_histories_in_grid(self, expected_histories, present=True): def get_histories(self): return self.histories_get_history_names() + def add_tag(self, tags_cell, tag): + tag_button = tags_cell.find_element(By.CSS_SELECTOR, ".stateless-tags button") + tag_button.click() + tag_input = tags_cell.find_element(By.CSS_SELECTOR, ".stateless-tags input") + tag_input.send_keys(tag) + self.send_enter(tag_input) + self.send_escape(tag_input) + self.sleep_for(self.wait_types.UX_RENDER) + def setup_shared_state(self): TestSavedHistories.user_email = self._get_random_email() TestSavedHistories.history1_name = self._get_random_name() @@ -239,17 +242,3 @@ def setup_shared_state(self): def create_history(self, name): self.home() self.history_panel_create_new_with_name(name) - - def get_history_tags_cell(self, history_name): - tags_cell = None - grid = self.wait_for_selector("#histories-grid") - for row in grid.find_elements(By.TAG_NAME, "tr"): - td = row.find_elements(By.TAG_NAME, "td") - if td[0].text == history_name: - tags_cell = td[3] - break - - if tags_cell is None: - raise AssertionError(f"Failed to find tag cell for history with name [{history_name}]") - - return tags_cell