Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Retry failed clicks more aggressively for Selenium tests. #4582

Merged
merged 1 commit into from Sep 10, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
79 changes: 27 additions & 52 deletions test/galaxy_selenium/navigates_galaxy.py
Expand Up @@ -303,8 +303,7 @@ def perform_upload(self, test_path, ext=None, genome=None, ext_all=None, genome_

self.upload_start()

close_button = self.wait_for_selector_clickable("button#btn-close")
close_button.click()
self.wait_for_and_click_selector("button#btn-close")

def upload_list(self, test_paths, name="test", ext=None, genome=None, hide_source_items=True):
self._collection_upload_start(test_paths, ext, genome, "List")
Expand Down Expand Up @@ -353,16 +352,12 @@ def _collection_upload_start(self, test_paths, ext, genome, collection_type):
self.upload_start(tab_id="collection")
self.upload_build()

@retry_during_transitions
def upload_tab_click(self, tab):
tab_tag_id = "#tab-title-link-%s" % tab
tab_element = self.wait_for_selector_clickable(tab_tag_id)
tab_element.click()
self.wait_for_and_click_selector(tab_tag_id)

@retry_during_transitions
def upload_start_click(self):
upload_button = self.wait_for_selector_clickable(".upload-button")
upload_button.click()
self.wait_for_and_click_selector(".upload-button")

@retry_during_transitions
def upload_set_footer_extension(self, ext, tab_id="regular"):
Expand All @@ -383,10 +378,8 @@ def upload_set_collection_type(self, collection_type):
self.wait_for_selector_visible(".upload-footer-collection-type")
self.select2_set_value(".upload-footer-collection-type", collection_type)

@retry_during_transitions
def upload_start(self, tab_id="regular"):
start_button = self.wait_for_selector_clickable("div#%s button#btn-start" % tab_id)
start_button.click()
self.wait_for_and_click_selector("div#%s button#btn-start" % tab_id)

@retry_during_transitions
def upload_build(self):
Expand All @@ -399,8 +392,7 @@ def upload_build(self):
build_button.click()

def upload_queue_local_file(self, test_path, tab_id="regular"):
local_upload_button = self.wait_for_selector_clickable("div#%s button#btn-local" % tab_id)
local_upload_button.click()
self.wait_for_and_click_selector("div#%s button#btn-local" % tab_id)

file_upload = self.wait_for_selector('div#%s input[type="file"]' % tab_id)
file_upload.send_keys(test_path)
Expand All @@ -417,16 +409,11 @@ def workflow_index_table_elements(self):
def workflow_index_table_row(self, workflow_index=0):
return self.workflow_index_table_elements()[workflow_index]

@retry_during_transitions
def workflow_index_click_search(self):
search_element = self.wait_for_selector_clickable("input.search-wf")
search_element.click()
return search_element
return self.wait_for_and_click_selector("input.search-wf")

@retry_during_transitions
def workflow_index_click_import(self):
element = self.wait_for_selector_clickable(self.test_data["selectors"]["workflows"]["import_button"])
element.click()
self.wait_for_and_click_selector(self.test_data["selectors"]["workflows"]["import_button"])

def workflow_index_rename(self, new_name, workflow_index=0):
self.workflow_index_click_option("Rename", workflow_index=workflow_index)
Expand Down Expand Up @@ -471,8 +458,7 @@ def workflow_import_submit_url(self, url):
self.click_submit(form_element)

def workflow_sharing_click_publish(self):
button = self.wait_for_selector_clickable("input[name='make_accessible_and_publish']")
button.click()
self.wait_for_and_click_selector("input[name='make_accessible_and_publish']")

def tagging_add(self, tags, auto_closes=True, parent_selector=""):

Expand All @@ -486,12 +472,10 @@ def tagging_add(self, tags, auto_closes=True, parent_selector=""):
self.send_enter(tag_area)

def workflow_run_submit(self):
button = self.wait_for_selector_clickable("button.btn-primary")
button.click()
self.wait_for_and_click_selector("button.btn-primary")

def tool_open(self, tool_id):
link_element = self.wait_for_selector('a[href$="tool_runner?tool_id=%s"]' % tool_id)
link_element.click()
self.wait_for_and_click_selector('a[href$="tool_runner?tool_id=%s"]' % tool_id)

def tool_parameter_div(self, expanded_parameter_id):
return self.wait_for_selector("div.ui-form-element[tour_id$='%s']" % expanded_parameter_id)
Expand All @@ -509,19 +493,16 @@ def tool_set_value(self, expanded_parameter_id, value, expected_type=None, test_
input_element.send_keys(value)

def tool_execute(self):
execute_button = self.wait_for_selector("button#execute")
execute_button.click()
self.wait_for_and_click_selector("button#execute")

def click_masthead_user(self):
self.click_xpath(self.navigation_data["selectors"]["masthead"]["user"])

def click_masthead_workflow(self):
self.click_xpath(self.navigation_data["selectors"]["masthead"]["workflow"])

@retry_during_transitions
def click_button_new_workflow(self):
element = self.wait_for_selector_clickable(self.navigation_data["selectors"]["workflows"]["new_button"])
element.click()
self.wait_for_and_click_selector(self.navigation_data["selectors"]["workflows"]["new_button"])

def wait_for_sizzle_selector_clickable(self, selector):
element = self._wait_on(
Expand Down Expand Up @@ -557,33 +538,27 @@ def history_options_menu_selector(self):
menu_selector = self.test_data["historyOptions"]["selectors"]["menu"]
return menu_selector

@retry_during_transitions
def history_panel_refresh_click(self):
refresh_item = self.wait_for_selector_clickable("#history-refresh-button")
refresh_item.click()
self.wait_for_and_click_selector("#history-refresh-button")

def history_panel_multi_operations_selector(self):
return self.test_data["historyPanel"]["selectors"]["history"]["multiOperationsIcon"]

def history_panel_multi_operations_show(self):
operations_selector = self.history_panel_multi_operations_selector()
operations_element = self.wait_for_selector_clickable(operations_selector)
operations_element.click()
self.wait_for_and_click_selector(operations_selector)

@retry_during_transitions
def history_panel_muli_operation_select_hid(self, hid):
item_selector = self.history_panel_item_selector(hid, wait=True)
operation_radio_selector = "%s .selector" % item_selector
element = self.wait_for_selector_clickable(operation_radio_selector)
element.click()
self.wait_for_and_click_selector(operation_radio_selector)

def history_panel_multi_operation_action_selector(self):
return self.test_data["historyPanel"]["selectors"]["history"]["multiOperationsActionBtn"]

def history_panel_multi_operation_action_click(self, action):
time.sleep(5)
button_element = self.wait_for_selector_clickable(self.history_panel_multi_operation_action_selector())
button_element.click()
self.wait_for_and_click_selector(self.history_panel_multi_operation_action_selector())
menu_element = self.wait_for_selector_visible(".list-action-menu.open")
action_element = menu_element.find_element_by_link_text(action)
action_element.click()
Expand Down Expand Up @@ -624,17 +599,15 @@ def hda_click_primary_action_button(self, hid, button_key):

button_def = self.test_data["historyPanel"]["hdaPrimaryActionButtons"][button_key]
button_selector = button_def["selector"]
button_item = self.wait_for_selector_visible("%s %s" % (buttons_selector, button_selector))
return button_item.click()
return self.wait_for_and_click_selector("%s %s" % (buttons_selector, button_selector))

def history_panel_click_item_title(self, **kwds):
if "hda_id" in kwds:
item_selector = self.hda_div_selector(kwds["hda_id"])
else:
item_selector = self.history_panel_item_selector(kwds["hid"])
title_selector = "%s .title" % item_selector
title_element = self.wait_for_selector(title_selector)
title_element.click()
self.wait_for_and_click_selector(title_selector)
if kwds.get("wait", False):
# Find a better way to wait for transition
time.sleep(.5)
Expand All @@ -648,17 +621,13 @@ def collection_builder_set_name(self, name):
name_element.send_keys(name)

def collection_builder_hide_originals(self):
hide_element = self.wait_for_selector_clickable("input.hide-originals")
hide_element.click()
self.wait_for_and_click_selector("input.hide-originals")

def collection_builder_create(self):
create_element = self.wait_for_selector_clickable("button.create-collection")
create_element.click()
self.wait_for_and_click_selector("button.create-collection")

@retry_during_transitions
def collection_builder_clear_filters(self):
clear_filter_link = self.wait_for_selector_visible("a.clear-filters-link")
clear_filter_link.click()
self.wait_for_and_click_selector("a.clear-filters-link")

def collection_builder_click_paired_item(self, forward_or_reverse, item):
assert forward_or_reverse in ["forward", "reverse"]
Expand Down Expand Up @@ -773,6 +742,12 @@ def run_tour_step(self, step, step_index, tour_callback):
element = self.tour_wait_for_clickable_element(postclick_selector)
element.click()

@retry_during_transitions
def wait_for_and_click_selector(self, selector):
element = self.wait_for_selector_clickable(selector)
element.click()
return element

def select2_set_value(self, container_selector, value, with_click=True):
# There are two hacky was to select things from the select2 widget -
# with_click=True: This simulates the mouse click after the suggestion contains
Expand Down
8 changes: 4 additions & 4 deletions test/selenium_tests/test_history_panel.py
Expand Up @@ -59,8 +59,8 @@ def test_history_tags_and_annotations_buttons(self):
tag_area_selector = self.test_data["historyPanel"]["selectors"]["history"]["tagArea"]
anno_area_selector = self.test_data["historyPanel"]["selectors"]["history"]["annoArea"]

tag_icon = self.wait_for_selector(tag_icon_selector)
annon_icon = self.wait_for_selector(anno_icon_selector)
tag_icon = self.wait_for_selector_clickable(tag_icon_selector)
annon_icon = self.wait_for_selector_clickable(anno_icon_selector)

self.assert_selector_absent_or_hidden(tag_area_selector)
self.assert_selector_absent_or_hidden(anno_area_selector)
Expand All @@ -83,6 +83,7 @@ def test_history_tags_and_annotations_buttons(self):
self.assert_selector_absent_or_hidden(tag_area_selector)
self.assert_selector_absent_or_hidden(anno_area_selector)

@selenium_test
def test_refresh_preserves_state(self):
self.register()
self.perform_upload(self.get_filename("1.txt"))
Expand All @@ -107,8 +108,7 @@ def test_refresh_preserves_state(self):
self.assert_selector_absent_or_hidden(hda_body_selector)

def click_history_refresh(self):
refresh_button_element = self.wait_for_selector('a#history-refresh-button')
refresh_button_element.click()
self.wait_for_and_click_selector('a#history-refresh-button')

def click_to_rename_history(self):
self.history_panel_name_element().click()
Expand Down