Skip to content

Commit

Permalink
Move grid cell selector helper to navigates galaxy
Browse files Browse the repository at this point in the history
  • Loading branch information
guerler committed Dec 28, 2023
1 parent 70b2417 commit ca8f9ac
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 23 deletions.
14 changes: 14 additions & 0 deletions lib/galaxy/selenium/navigates_galaxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
35 changes: 12 additions & 23 deletions lib/galaxy_test/selenium/test_histories_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down Expand Up @@ -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()
Expand All @@ -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

0 comments on commit ca8f9ac

Please sign in to comment.