From 23afbb64e24b0fb7b8bbc3fda2019ae150b971d2 Mon Sep 17 00:00:00 2001 From: Nicola Soranzo Date: Sun, 26 Jun 2022 00:20:49 +0100 Subject: [PATCH] Updates for stuff removed in Selenium 4.3.0 --- lib/galaxy/selenium/driver_factory.py | 5 +- lib/galaxy/selenium/has_driver.py | 24 ++--- lib/galaxy/selenium/navigates_galaxy.py | 97 ++++++++++--------- lib/galaxy_test/selenium/framework.py | 2 +- lib/galaxy_test/selenium/test_admin_app.py | 28 +++--- .../selenium/test_change_password.py | 8 +- .../selenium/test_collection_builders.py | 6 +- .../selenium/test_collection_edit.py | 5 +- .../selenium/test_custom_builds.py | 12 ++- .../selenium/test_histories_list.py | 16 +-- .../test_history_panel_collections.py | 5 +- lib/galaxy_test/selenium/test_jupyter.py | 4 +- .../selenium/test_library_contents.py | 3 +- .../selenium/test_library_landing.py | 4 +- lib/galaxy_test/selenium/test_pages.py | 4 +- .../selenium/test_personal_information.py | 18 ++-- .../selenium/test_published_histories_grid.py | 12 ++- lib/galaxy_test/selenium/test_sign_out.py | 4 +- lib/galaxy_test/selenium/test_tool_form.py | 19 ++-- lib/galaxy_test/selenium/test_uploads.py | 7 +- .../selenium/test_workflow_editor.py | 7 +- .../selenium/test_workflow_management.py | 6 +- lib/galaxy_test/selenium/test_workflow_run.py | 8 +- .../test_admin_dependencies.py | 8 +- .../test_toolbox_filters.py | 5 +- 25 files changed, 176 insertions(+), 141 deletions(-) diff --git a/lib/galaxy/selenium/driver_factory.py b/lib/galaxy/selenium/driver_factory.py index 118e6d12692..ba06dac54de 100644 --- a/lib/galaxy/selenium/driver_factory.py +++ b/lib/galaxy/selenium/driver_factory.py @@ -25,7 +25,7 @@ DEFAULT_SELENIUM_REMOTE_PORT = "4444" DEFAULT_SELENIUM_REMOTE_HOST = "127.0.0.1" DEFAULT_WINDOW_WIDTH = 1280 DEFAULT_WINDOW_HEIGHT = 1000 -VALID_LOCAL_BROWSERS = ["CHROME", "FIREFOX", "OPERA"] +VALID_LOCAL_BROWSERS = ["CHROME", "FIREFOX"] class ConfiguredDriver: @@ -87,7 +87,6 @@ def get_local_driver(browser=DEFAULT_BROWSER, headless=False) -> WebDriver: driver_to_class = { "CHROME": webdriver.Chrome, "FIREFOX": webdriver.Firefox, - "OPERA": webdriver.Opera, } driver_class = driver_to_class[browser] if browser == "CHROME": @@ -114,7 +113,7 @@ def get_remote_driver(host, port, browser=DEFAULT_BROWSER) -> WebDriver: # docker run -d -p 4444:4444 -v /dev/shm:/dev/shm selenium/standalone-chrome:3.0.1-aluminum if browser == "auto": browser = "CHROME" - assert browser in ["CHROME", "EDGE", "ANDROID", "FIREFOX", "INTERNETEXPLORER", "IPAD", "IPHONE", "OPERA", "SAFARI"] + assert browser in ["CHROME", "EDGE", "ANDROID", "FIREFOX", "INTERNETEXPLORER", "IPAD", "IPHONE", "SAFARI"] desired_capabilities = getattr(DesiredCapabilities, browser) desired_capabilities["loggingPrefs"] = LOGGING_PREFS executor = f"http://{host}:{port}/wd/hub" diff --git a/lib/galaxy/selenium/has_driver.py b/lib/galaxy/selenium/has_driver.py index f155cb5ed2f..b22830ea749 100644 --- a/lib/galaxy/selenium/has_driver.py +++ b/lib/galaxy/selenium/has_driver.py @@ -10,7 +10,7 @@ from selenium.webdriver.common.by import By from selenium.webdriver.common.keys import Keys from selenium.webdriver.remote.webdriver import WebDriver from selenium.webdriver.support import expected_conditions as ec -from selenium.webdriver.support.ui import WebDriverWait +from selenium.webdriver.support.wait import WebDriverWait UNSPECIFIED_TIMEOUT = object() @@ -28,13 +28,13 @@ class HasDriver: driver.get(new_url) def assert_xpath(self, xpath): - assert self.driver.find_element_by_xpath(xpath) + assert self.driver.find_element(By.XPATH, xpath) def assert_selector(self, selector): - assert self.driver.find_element_by_css_selector(selector) + assert self.driver.find_element(By.CSS_SELECTOR, selector) def assert_selector_absent_or_hidden(self, selector): - elements = self.driver.find_elements_by_css_selector(selector) + elements = self.driver.find_elements(By.CSS_SELECTOR, selector) for element in elements: assert not element.is_displayed() @@ -44,7 +44,7 @@ class HasDriver: assert not element.is_displayed() def selector_is_displayed(self, selector): - element = self.driver.find_element_by_css_selector(selector) + element = self.driver.find_element(By.CSS_SELECTOR, selector) return element.is_displayed() def is_displayed(self, selector_template): @@ -52,7 +52,7 @@ class HasDriver: return element.is_displayed() def assert_selector_absent(self, selector): - assert len(self.driver.find_elements_by_css_selector(selector)) == 0 + assert len(self.driver.find_elements(By.CSS_SELECTOR, selector)) == 0 def find_elements(self, selector_template): return self.driver.find_elements(*selector_template.element_locator) @@ -133,7 +133,7 @@ class HasDriver: def wait_for_selector_absent(self, selector, **kwds): element = self._wait_on( - lambda driver: len(driver.find_elements_by_css_selector(selector)) == 0, + lambda driver: len(driver.find_elements(By.CSS_SELECTOR, selector)) == 0, f"CSS selector [{selector}] to become absent", **kwds, ) @@ -203,24 +203,24 @@ class HasDriver: return WebDriverWait(self.driver, timeout) def click_xpath(self, xpath): - element = self.driver.find_element_by_xpath(xpath) + element = self.driver.find_element(By.XPATH, xpath) element.click() def click_label(self, text): - element = self.driver.find_element_by_link_text(text) + element = self.driver.find_element(By.LINK_TEXT, text) element.click() def click_selector(self, selector): - element = self.driver.find_element_by_css_selector(selector) + element = self.driver.find_element(By.CSS_SELECTOR, selector) element.click() def fill(self, form, info): for key, value in info.items(): - input_element = form.find_element_by_name(key) + input_element = form.find_element(By.NAME, key) input_element.send_keys(value) def click_submit(self, form): - submit_button = form.find_element_by_css_selector("input[type='submit']") + submit_button = form.find_element(By.CSS_SELECTOR, "input[type='submit']") submit_button.click() def prepend_timeout_message(self, timeout_exception, message): diff --git a/lib/galaxy/selenium/navigates_galaxy.py b/lib/galaxy/selenium/navigates_galaxy.py index 37b76b650b6..ed22c8fe783 100644 --- a/lib/galaxy/selenium/navigates_galaxy.py +++ b/lib/galaxy/selenium/navigates_galaxy.py @@ -23,6 +23,7 @@ from typing import ( import requests import yaml +from selenium.webdriver.common.by import By from selenium.webdriver.common.keys import Keys from selenium.webdriver.remote.webdriver import WebDriver @@ -531,8 +532,8 @@ class NavigatesGalaxy(HasDriver): def click_grid_popup_option(self, item_name, option_label): item_button = None grid = self.components.grids.body.wait_for_visible() - for row in grid.find_elements_by_tag_name("tr"): - name_cell = row.find_elements_by_tag_name("td")[1] + for row in grid.find_elements(By.TAG_NAME, "tr"): + name_cell = row.find_elements(By.TAG_NAME, "td")[1] if name_cell.text == item_name: item_button = name_cell break @@ -540,9 +541,9 @@ class NavigatesGalaxy(HasDriver): if item_button is None: raise AssertionError(f"Failed to find item with name [{item_name}]") - popup_menu_button = item_button.find_element_by_css_selector(".dropdown-toggle") + popup_menu_button = item_button.find_element(By.CSS_SELECTOR, ".dropdown-toggle") popup_menu_button.click() - popup_option = self.driver.find_element_by_link_text(option_label) + popup_option = self.driver.find_element(By.LINK_TEXT, option_label) popup_option.click() def published_grid_search_for(self, search_term=None): @@ -662,7 +663,7 @@ class NavigatesGalaxy(HasDriver): try: username_element = self.components.masthead.username.wait_for_visible() except self.TimeoutException as e: - menu_items = user_menu.find_elements_by_css_selector("li a") + menu_items = user_menu.find_elements(By.CSS_SELECTOR, "li a") menu_text = [mi.text for mi in menu_items] message = f"Failed to find logged in message in menu items {', '.join(menu_text)}" raise self.prepend_timeout_message(e, message) @@ -695,7 +696,7 @@ class NavigatesGalaxy(HasDriver): def click_center(self): action_chains = self.action_chains() - center_element = self.driver.find_element_by_css_selector("#center") + center_element = self.driver.find_element(By.CSS_SELECTOR, "#center") action_chains.move_to_element(center_element).click().perform() def perform_upload(self, test_path, **kwd): @@ -900,7 +901,7 @@ class NavigatesGalaxy(HasDriver): rule_builder = self.components.rule_builder rule_builder.menu_button_filter.wait_for_and_click() with self.rule_builder_rule_editor("add-filter-count") as editor_element: - filter_input = editor_element.find_element_by_css_selector("input[type='number']") + filter_input = editor_element.find_element(By.CSS_SELECTOR, "input[type='number']") filter_input.clear() filter_input.send_keys(f"{count}") @@ -908,7 +909,7 @@ class NavigatesGalaxy(HasDriver): rule_builder = self.components.rule_builder rule_builder.menu_button_rules.wait_for_and_click() with self.rule_builder_rule_editor("sort") as editor_element: - column_elem = editor_element.find_element_by_css_selector(".rule-column-selector") + column_elem = editor_element.find_element(By.CSS_SELECTOR, ".rule-column-selector") self.select2_set_value(column_elem, column_label) self.screenshot_if(screenshot_name) @@ -917,17 +918,17 @@ class NavigatesGalaxy(HasDriver): rule_builder.menu_button_column.wait_for_and_click() with self.rule_builder_rule_editor("add-column-regex") as editor_element: - column_elem = editor_element.find_element_by_css_selector(".rule-column-selector") + column_elem = editor_element.find_element(By.CSS_SELECTOR, ".rule-column-selector") self.select2_set_value(column_elem, column_label) - groups_elem = editor_element.find_element_by_css_selector("input[type='radio'][value='groups']") + groups_elem = editor_element.find_element(By.CSS_SELECTOR, "input[type='radio'][value='groups']") groups_elem.click() - regex_elem = editor_element.find_element_by_css_selector("input.rule-regular-expression") + regex_elem = editor_element.find_element(By.CSS_SELECTOR, "input.rule-regular-expression") regex_elem.clear() regex_elem.send_keys(regex) - filter_input = editor_element.find_element_by_css_selector("input[type='number']") + filter_input = editor_element.find_element(By.CSS_SELECTOR, "input[type='number']") filter_input.clear() filter_input.send_keys(f"{group_count}") @@ -938,17 +939,17 @@ class NavigatesGalaxy(HasDriver): rule_builder.menu_button_column.wait_for_and_click() with self.rule_builder_rule_editor("add-column-regex") as editor_element: - column_elem = editor_element.find_element_by_css_selector(".rule-column-selector") + column_elem = editor_element.find_element(By.CSS_SELECTOR, ".rule-column-selector") self.select2_set_value(column_elem, column_label) - groups_elem = editor_element.find_element_by_css_selector("input[type='radio'][value='replacement']") + groups_elem = editor_element.find_element(By.CSS_SELECTOR, "input[type='radio'][value='replacement']") groups_elem.click() - regex_elem = editor_element.find_element_by_css_selector("input.rule-regular-expression") + regex_elem = editor_element.find_element(By.CSS_SELECTOR, "input.rule-regular-expression") regex_elem.clear() regex_elem.send_keys(regex) - filter_input = editor_element.find_element_by_css_selector("input.rule-replacement") + filter_input = editor_element.find_element(By.CSS_SELECTOR, "input.rule-replacement") filter_input.clear() filter_input.send_keys(f"{replacement}") @@ -958,7 +959,7 @@ class NavigatesGalaxy(HasDriver): rule_builder = self.components.rule_builder rule_builder.menu_button_column.wait_for_and_click() with self.rule_builder_rule_editor("add-column-value") as editor_element: - filter_input = editor_element.find_element_by_css_selector("input[type='text']") + filter_input = editor_element.find_element(By.CSS_SELECTOR, "input[type='text']") filter_input.clear() filter_input.send_keys(value) @@ -968,7 +969,7 @@ class NavigatesGalaxy(HasDriver): rule_builder = self.components.rule_builder rule_builder.menu_button_rules.wait_for_and_click() with self.rule_builder_rule_editor("remove-columns") as filter_editor_element: - column_elem = filter_editor_element.find_element_by_css_selector(".rule-column-selector") + column_elem = filter_editor_element.find_element(By.CSS_SELECTOR, ".rule-column-selector") for column_label in column_labels: self.select2_set_value(column_elem, column_label) self.screenshot_if(screenshot_name) @@ -977,9 +978,9 @@ class NavigatesGalaxy(HasDriver): rule_builder = self.components.rule_builder rule_builder.menu_button_column.wait_for_and_click() with self.rule_builder_rule_editor("add-column-concatenate") as filter_editor_element: - column_elems = filter_editor_element.find_elements_by_css_selector(".rule-column-selector") + column_elems = filter_editor_element.find_elements(By.CSS_SELECTOR, ".rule-column-selector") self.select2_set_value(column_elems[0], column_label_1) - column_elems = filter_editor_element.find_elements_by_css_selector(".rule-column-selector") + column_elems = filter_editor_element.find_elements(By.CSS_SELECTOR, ".rule-column-selector") self.select2_set_value(column_elems[1], column_label_2) self.screenshot_if(screenshot_name) @@ -987,13 +988,13 @@ class NavigatesGalaxy(HasDriver): rule_builder = self.components.rule_builder rule_builder.menu_button_rules.wait_for_and_click() with self.rule_builder_rule_editor("split-columns") as filter_editor_element: - column_elems = filter_editor_element.find_elements_by_css_selector(".rule-column-selector") + column_elems = filter_editor_element.find_elements(By.CSS_SELECTOR, ".rule-column-selector") clear = True for column_label_1 in column_labels_1: self.select2_set_value(column_elems[0], column_label_1, clear_value=clear) clear = False - column_elems = filter_editor_element.find_elements_by_css_selector(".rule-column-selector") + column_elems = filter_editor_element.find_elements(By.CSS_SELECTOR, ".rule-column-selector") clear = True for column_label_2 in column_labels_2: self.select2_set_value(column_elems[1], column_label_2, clear_value=clear) @@ -1005,9 +1006,9 @@ class NavigatesGalaxy(HasDriver): rule_builder = self.components.rule_builder rule_builder.menu_button_rules.wait_for_and_click() with self.rule_builder_rule_editor("swap-columns") as filter_editor_element: - column_elems = filter_editor_element.find_elements_by_css_selector(".rule-column-selector") + column_elems = filter_editor_element.find_elements(By.CSS_SELECTOR, ".rule-column-selector") self.select2_set_value(column_elems[0], column_label_1) - column_elems = filter_editor_element.find_elements_by_css_selector(".rule-column-selector") + column_elems = filter_editor_element.find_elements(By.CSS_SELECTOR, ".rule-column-selector") self.select2_set_value(column_elems[1], column_label_2) self.screenshot_if(screenshot_name) @@ -1057,7 +1058,7 @@ class NavigatesGalaxy(HasDriver): def workflow_editor_click_option(self, option_label): self.workflow_editor_click_options() menu_element = self.workflow_editor_options_menu_element() - option_elements = menu_element.find_elements_by_css_selector("a") + option_elements = menu_element.find_elements(By.CSS_SELECTOR, "a") assert len(option_elements) > 0, "Failed to find workflow editor options" self.sleep_for(WAIT_TYPES.UX_RENDER) found_option = False @@ -1130,19 +1131,19 @@ class NavigatesGalaxy(HasDriver): def libraries_open_with_name(self, name): self.libraries_open() self.libraries_index_search_for(name) - self.libraries_index_table_elements()[0].find_element_by_css_selector("td a").click() + self.libraries_index_table_elements()[0].find_element(By.CSS_SELECTOR, "td a").click() @retry_during_transitions def libraries_index_table_elements(self): container = self.components.libraries._.wait_for_visible() - elements = container.find_elements_by_css_selector("tbody") + elements = container.find_elements(By.CSS_SELECTOR, "tbody") if not elements: return [] else: assert len(elements) == 1 element = elements[0] - return element.find_elements_by_css_selector("tr") # [style='display: table-row'] + return element.find_elements(By.CSS_SELECTOR, "tr") # [style='display: table-row'] def libraries_index_create(self, name): self.components.libraries.create_new_library_btn.wait_for_and_click() @@ -1195,7 +1196,7 @@ class NavigatesGalaxy(HasDriver): found = False for history_element in history_elements: if to_select_item in history_element.text: - history_element.find_element_by_css_selector("input").click() + history_element.find_element(By.CSS_SELECTOR, "input").click() found = True break @@ -1210,7 +1211,7 @@ class NavigatesGalaxy(HasDriver): def libraries_table_elements(self): tbody_element = self.wait_for_selector_visible("#folder_list_body > tbody") - return tbody_element.find_elements_by_css_selector("tr:not(.b-table-empty-row)") + return tbody_element.find_elements(By.CSS_SELECTOR, "tr:not(.b-table-empty-row)") def populate_library_folder_from_import_dir(self, library_name, filenames): self.libraries_open_with_name(library_name) @@ -1228,7 +1229,7 @@ class NavigatesGalaxy(HasDriver): def clear_tooltips(self): action_chains = self.action_chains() - center_element = self.driver.find_element_by_css_selector("#center") + center_element = self.driver.find_element(By.CSS_SELECTOR, "#center") action_chains.move_to_element(center_element).perform() self.wait_for_selector_absent_or_hidden(".b-tooltip", wait_type=WAIT_TYPES.UX_POPUP) @@ -1248,7 +1249,7 @@ class NavigatesGalaxy(HasDriver): @retry_during_transitions def workflow_index_column_text(self, column_index, workflow_index=0): row_element = self.workflow_index_table_row(workflow_index=workflow_index) - columns = row_element.find_elements_by_css_selector("td") + columns = row_element.find_elements(By.CSS_SELECTOR, "td") return columns[column_index].text def workflow_index_click_search(self): @@ -1275,18 +1276,18 @@ class NavigatesGalaxy(HasDriver): def workflow_index_name(self, workflow_index=0): """Get workflow name for workflow_index'th row.""" row_element = self.workflow_index_table_row(workflow_index=workflow_index) - workflow_button = row_element.find_element_by_css_selector(".workflow-dropdown") + workflow_button = row_element.find_element(By.CSS_SELECTOR, ".workflow-dropdown") return workflow_button.text @retry_during_transitions def workflow_click_option(self, workflow_selector, workflow_index=0): workflow_row = self.workflow_index_table_row(workflow_index=workflow_index) - workflow_button = workflow_row.find_element_by_css_selector(workflow_selector) + workflow_button = workflow_row.find_element(By.CSS_SELECTOR, workflow_selector) workflow_button.click() def select_dropdown_item(self, option_title): menu_element = self.wait_for_selector_visible(".dropdown-menu.show") - menu_options = menu_element.find_elements_by_css_selector("a.dropdown-item") + menu_options = menu_element.find_elements(By.CSS_SELECTOR, "a.dropdown-item") for menu_option in menu_options: if option_title in menu_option.text: menu_option.click() @@ -1299,7 +1300,7 @@ class NavigatesGalaxy(HasDriver): def workflow_index_click_tag_display(self, workflow_index=0): workflow_row_element = self.workflow_index_table_row(workflow_index) - tag_display = workflow_row_element.find_element_by_css_selector(".tags-display") + tag_display = workflow_row_element.find_element(By.CSS_SELECTOR, ".tags-display") tag_display.click() def workflow_index_add_tag(self, tag: str, workflow_index: int = 0): @@ -1317,8 +1318,8 @@ class NavigatesGalaxy(HasDriver): @retry_during_transitions def workflow_index_tag_elements(self, workflow_index=0): workflow_row_element = self.workflow_index_table_row(workflow_index) - tag_display = workflow_row_element.find_element_by_css_selector(".tags-display") - tag_spans = tag_display.find_elements_by_css_selector(".tag-name") + tag_display = workflow_row_element.find_element(By.CSS_SELECTOR, ".tags-display") + tag_spans = tag_display.find_elements(By.CSS_SELECTOR, ".tag-name") return tag_spans @retry_during_transitions @@ -1433,7 +1434,7 @@ class NavigatesGalaxy(HasDriver): def tool_parameter_edit_rules(self): rules_div_element = self.tool_parameter_div("rules") - edit_button_element = rules_div_element.find_element_by_css_selector("i.fa-edit") + edit_button_element = rules_div_element.find_element(By.CSS_SELECTOR, "i.fa-edit") edit_button_element.click() def tool_set_value(self, expanded_parameter_id, value, expected_type=None): @@ -1443,7 +1444,7 @@ class NavigatesGalaxy(HasDriver): div_selector = f"div.ui-form-element[id$='form-element-{expanded_parameter_id}']" self.select2_set_value(div_selector, value) else: - input_element = div_element.find_element_by_css_selector("input") + input_element = div_element.find_element(By.CSS_SELECTOR, "input") # Clear default value input_element.clear() input_element.send_keys(value) @@ -1577,8 +1578,8 @@ class NavigatesGalaxy(HasDriver): self.sleep_for(self.wait_types.UX_RENDER) names = [] grid = self.wait_for_selector("#grid-table-body") - for row in grid.find_elements_by_tag_name("tr"): - td = row.find_elements_by_tag_name("td") + for row in grid.find_elements(By.TAG_NAME, "tr"): + td = row.find_elements(By.TAG_NAME, "td") name = td[1].text if td[0].text == "" else td[0].text if name != "No items" and not name.startswith("No matching entries found"): names.append(name) @@ -1649,7 +1650,7 @@ class NavigatesGalaxy(HasDriver): @retry_during_transitions def _click_action_in_menu(): menu_element = self.wait_for_visible(self.navigation.history_panel.multi_operations.selectors.action_menu) - menu_element.find_element_by_link_text(action.text).click() + menu_element.find_element(By.LINK_TEXT, action.text).click() _click_action_in_menu() @@ -1698,7 +1699,7 @@ class NavigatesGalaxy(HasDriver): def history_panel_item_available_visualizations_elements(self, hid): # Precondition: viz menu has been opened with history_panel_item_click_visualization_menu viz_menu_selectors = f"{self.history_panel_item_selector(hid)} a.visualization-link" - return self.driver.find_elements_by_css_selector(viz_menu_selectors) + return self.driver.find_elements(By.CSS_SELECTOR, viz_menu_selectors) def history_panel_item_get_tags(self, hid): item_component = self.history_panel_item_component(hid=hid) @@ -1789,7 +1790,7 @@ class NavigatesGalaxy(HasDriver): def collection_builder_click_paired_item(self, forward_or_reverse, item): assert forward_or_reverse in ["forward", "reverse"] forward_column = self.wait_for_selector_visible(f".{forward_or_reverse}-column .column-datasets") - first_datset_forward = forward_column.find_elements_by_css_selector("li")[item] + first_datset_forward = forward_column.find_elements(By.CSS_SELECTOR, "li")[item] first_datset_forward.click() def logout_if_needed(self): @@ -2029,12 +2030,12 @@ class NavigatesGalaxy(HasDriver): # doesn't seem to work with the tool form for some reason. if hasattr(container_selector_or_elem, "selector"): container_selector_or_elem = container_selector_or_elem.selector - if not hasattr(container_selector_or_elem, "find_element_by_css_selector"): + if not hasattr(container_selector_or_elem, "find_element"): container_elem = self.wait_for_selector(container_selector_or_elem) else: container_elem = container_selector_or_elem - text_element = container_elem.find_element_by_css_selector("input[type='text']") + text_element = container_elem.find_element(By.CSS_SELECTOR, "input[type='text']") if clear_value: self.send_backspace(text_element) self.send_backspace(text_element) @@ -2047,7 +2048,7 @@ class NavigatesGalaxy(HasDriver): # Wait for select2 options to load and then click to add this one. self.send_enter(text_element) else: - select_elem = drop_elem.find_elements_by_css_selector(".select2-result-label")[0] + select_elem = drop_elem.find_elements(By.CSS_SELECTOR, ".select2-result-label")[0] action_chains = self.action_chains() action_chains.move_to_element(select_elem).click().perform() self.wait_for_selector_absent_or_hidden("#select2-drop") diff --git a/lib/galaxy_test/selenium/framework.py b/lib/galaxy_test/selenium/framework.py index 362640e1ba5..ac09042419a 100644 --- a/lib/galaxy_test/selenium/framework.py +++ b/lib/galaxy_test/selenium/framework.py @@ -69,7 +69,7 @@ DEFAULT_DOWNLOAD_PATH = driver_factory.DEFAULT_DOWNLOAD_PATH TIMEOUT_MULTIPLIER = float(os.environ.get("GALAXY_TEST_TIMEOUT_MULTIPLIER", DEFAULT_TIMEOUT_MULTIPLIER)) GALAXY_TEST_ERRORS_DIRECTORY = os.environ.get("GALAXY_TEST_ERRORS_DIRECTORY", DEFAULT_TEST_ERRORS_DIRECTORY) GALAXY_TEST_SCREENSHOTS_DIRECTORY = os.environ.get("GALAXY_TEST_SCREENSHOTS_DIRECTORY", None) -# Test browser can be ["CHROME", "FIREFOX", "OPERA"] +# Test browser can be ["CHROME", "FIREFOX"] GALAXY_TEST_SELENIUM_BROWSER = os.environ.get("GALAXY_TEST_SELENIUM_BROWSER", driver_factory.DEFAULT_SELENIUM_BROWSER) GALAXY_TEST_SELENIUM_REMOTE = os.environ.get("GALAXY_TEST_SELENIUM_REMOTE", driver_factory.DEFAULT_SELENIUM_REMOTE) GALAXY_TEST_SELENIUM_REMOTE_PORT = os.environ.get( diff --git a/lib/galaxy_test/selenium/test_admin_app.py b/lib/galaxy_test/selenium/test_admin_app.py index a5749dbb887..3a18b032f44 100644 --- a/lib/galaxy_test/selenium/test_admin_app.py +++ b/lib/galaxy_test/selenium/test_admin_app.py @@ -1,3 +1,5 @@ +from selenium.webdriver.common.by import By + from galaxy_test.base.populators import flakey from .framework import ( selenium_test, @@ -23,7 +25,7 @@ class AdminAppTestCase(SeleniumTestCase): self.sleep_for(self.wait_types.UX_RENDER) self.screenshot("admin_allowlist_local_landing") # This should be updated if the list of built-in converters is changed. - render_button = self.driver.find_element_by_xpath("//td[.='CONVERTER_bam_to_bigwig_0']/following::td/button") + render_button = self.driver.find_element(By.XPATH, "//td[.='CONVERTER_bam_to_bigwig_0']/following::td/button") render_button.click() self.sleep_for(self.wait_types.UX_RENDER) self.screenshot("admin_allowlist_converter_html_rendered") @@ -31,7 +33,7 @@ class AdminAppTestCase(SeleniumTestCase): self.sleep_for(self.wait_types.UX_RENDER) self.screenshot("admin_allowlist_render_landing") self.sleep_for(self.wait_types.UX_RENDER) - sanitize_button = self.driver.find_element_by_xpath("//td[.='CONVERTER_bam_to_bigwig_0']/following::td/button") + sanitize_button = self.driver.find_element(By.XPATH, "//td[.='CONVERTER_bam_to_bigwig_0']/following::td/button") sanitize_button.click() self.sleep_for(self.wait_types.UX_RENDER) self.screenshot("admin_allowlist_converter_sanitized") @@ -58,7 +60,7 @@ class AdminAppTestCase(SeleniumTestCase): admin_component.index.toolshed.wait_for_and_click() self.sleep_for(self.wait_types.UX_RENDER) self.screenshot("admin_toolshed_landing") - repo_search_input = self.driver.find_element_by_id("toolshed-repo-search") + repo_search_input = self.driver.find_element(By.ID, "toolshed-repo-search") repo_search_input.clear() repo_search_input.send_keys(repository_name) # If this hasn't succeeded after 30 seconds, the @flakey context should @@ -67,33 +69,33 @@ class AdminAppTestCase(SeleniumTestCase): self.sleep_for(self.wait_types.SHED_SEARCH) self.screenshot("admin_toolshed_search") admin_component.toolshed.search_results.wait_for_visible() - repository_row = self.driver.find_element_by_link_text(repository_name) + repository_row = self.driver.find_element(By.LINK_TEXT, repository_name) repository_row.click() self.sleep_for(self.wait_types.UX_RENDER) self.screenshot("admin_toolshed_repo_details") - install_button = self.driver.find_element_by_xpath("(//button[contains(., 'Install')])[2]") + install_button = self.driver.find_element(By.XPATH, "(//button[contains(., 'Install')])[2]") install_button.click() self.sleep_for(self.wait_types.UX_RENDER) self.screenshot("admin_toolshed_repo_install_settings") self.sleep_for(self.wait_types.UX_TRANSITION) - ok_button = self.driver.find_element_by_xpath( - "//*[@id='repo-install-settings___BV_modal_footer_']/button[contains(., 'OK')]" + ok_button = self.driver.find_element( + By.XPATH, "//*[@id='repo-install-settings___BV_modal_footer_']/button[contains(., 'OK')]" ) ok_button.click() self.sleep_for(self.wait_types.REPO_INSTALL) - installed_only = self.driver.find_element_by_xpath("//span[contains(. ,'Installed Only')]/../../input") + installed_only = self.driver.find_element(By.XPATH, "//span[contains(. ,'Installed Only')]/../../input") self.action_chains().move_to_element(installed_only).click().perform() self.sleep_for(self.wait_types.UX_TRANSITION) # This serves as a check for the presence of the upgrade notification. admin_component.toolshed.upgrade_notification.wait_for_visible() self.screenshot("admin_toolshed_repo_installed") - repository_row = self.driver.find_element_by_xpath(f"//div[contains(text(), '{repository_name}')]/..") + repository_row = self.driver.find_element(By.XPATH, f"//div[contains(text(), '{repository_name}')]/..") repository_row.click() self.sleep_for(self.wait_types.UX_TRANSITION) self.screenshot("admin_toolshed_installed_only") # Unfortunately reusing the element isn't feasible, since the div # containing the button gets replaced with a new div and button. - uninstall_button = self.driver.find_element_by_xpath("(//button[contains(., 'Uninstall')])[1]") + uninstall_button = self.driver.find_element(By.XPATH, "(//button[contains(., 'Uninstall')])[1]") uninstall_button.click() self.sleep_for(self.wait_types.UX_TRANSITION) self.screenshot("admin_toolshed_repo_uninstalled") @@ -107,9 +109,9 @@ class AdminAppTestCase(SeleniumTestCase): admin_component.index.dependencies.wait_for_and_click() self.sleep_for(self.wait_types.UX_RENDER) # Ensure that tabs are visible - self.driver.find_element_by_link_text("Dependencies") - self.driver.find_element_by_link_text("Containers") - unused_link = self.driver.find_element_by_link_text("Unused") + self.driver.find_element(By.LINK_TEXT, "Dependencies") + self.driver.find_element(By.LINK_TEXT, "Containers") + unused_link = self.driver.find_element(By.LINK_TEXT, "Unused") # Ensure that #manage-resolver-type is visible. admin_component.manage_dependencies.resolver_type.wait_for_visible() self.screenshot("admin_dependencies_landing") diff --git a/lib/galaxy_test/selenium/test_change_password.py b/lib/galaxy_test/selenium/test_change_password.py index 15afee91b11..fca40ce47f6 100644 --- a/lib/galaxy_test/selenium/test_change_password.py +++ b/lib/galaxy_test/selenium/test_change_password.py @@ -1,3 +1,5 @@ +from selenium.webdriver.common.by import By + from .framework import ( selenium_test, SeleniumTestCase, @@ -62,7 +64,7 @@ class ChangePasswordTestCase(SeleniumTestCase): def fill_input_fields(self, current, password, confirm): self.sleep_for(self.wait_types.UX_TRANSITION) - self.driver.find_element_by_css_selector("input[id='current']").send_keys(current) - self.driver.find_element_by_css_selector("input[id='password']").send_keys(password) - self.driver.find_element_by_css_selector("input[id='confirm']").send_keys(confirm) + self.driver.find_element(By.CSS_SELECTOR, "input[id='current']").send_keys(current) + self.driver.find_element(By.CSS_SELECTOR, "input[id='password']").send_keys(password) + self.driver.find_element(By.CSS_SELECTOR, "input[id='confirm']").send_keys(confirm) self.components.change_user_password.submit.wait_for_and_click() diff --git a/lib/galaxy_test/selenium/test_collection_builders.py b/lib/galaxy_test/selenium/test_collection_builders.py index d9d9f05ed8f..db7960dadad 100644 --- a/lib/galaxy_test/selenium/test_collection_builders.py +++ b/lib/galaxy_test/selenium/test_collection_builders.py @@ -1,3 +1,5 @@ +from selenium.webdriver.common.by import By + from .framework import ( selenium_test, SeleniumTestCase, @@ -116,11 +118,11 @@ class CollectionBuildersTestCase(SeleniumTestCase): self.wait_for_and_click(self.navigation.collection_builders.selectors.clear_filters) forward_column = self.wait_for_visible(self.navigation.collection_builders.selectors.forward_datasets) - first_datset_forward = forward_column.find_elements_by_css_selector("li")[0] + first_datset_forward = forward_column.find_elements(By.CSS_SELECTOR, "li")[0] first_datset_forward.click() reverse_column = self.wait_for_visible(self.navigation.collection_builders.selectors.reverse_datasets) - second_dataset_reverse = reverse_column.find_elements_by_css_selector("li")[1] + second_dataset_reverse = reverse_column.find_elements(By.CSS_SELECTOR, "li")[1] second_dataset_reverse.click() self.collection_builder_hide_originals() diff --git a/lib/galaxy_test/selenium/test_collection_edit.py b/lib/galaxy_test/selenium/test_collection_edit.py index fcc2e934b7c..ef627223424 100644 --- a/lib/galaxy_test/selenium/test_collection_edit.py +++ b/lib/galaxy_test/selenium/test_collection_edit.py @@ -1,3 +1,4 @@ +from selenium.webdriver.common.by import By from selenium.webdriver.common.keys import Keys from .framework import ( @@ -48,8 +49,8 @@ class CollectionEditTestCase(SeleniumTestCase): def change_dbkey_value_and_click_submit(self, dbkeyValue, dbkeyNew): self.components.edit_collection_attributes.database_value(dbkey=dbkeyValue).wait_for_and_click() - self.driver.find_element_by_css_selector("input.multiselect__input").send_keys(dbkeyNew) - self.driver.find_element_by_css_selector("input.multiselect__input").send_keys(Keys.ENTER) + self.driver.find_element(By.CSS_SELECTOR, "input.multiselect__input").send_keys(dbkeyNew) + self.driver.find_element(By.CSS_SELECTOR, "input.multiselect__input").send_keys(Keys.ENTER) self.components.edit_collection_attributes.save_btn.wait_for_and_click() def _wait_for_and_select(self, hids): diff --git a/lib/galaxy_test/selenium/test_custom_builds.py b/lib/galaxy_test/selenium/test_custom_builds.py index 5b7bcb01770..b7592efcde8 100644 --- a/lib/galaxy_test/selenium/test_custom_builds.py +++ b/lib/galaxy_test/selenium/test_custom_builds.py @@ -1,3 +1,5 @@ +from selenium.webdriver.common.by import By + from .framework import ( retry_assertion_during_transitions, selenium_test, @@ -55,11 +57,11 @@ class CustomBuildsTestcase(SharedStateSeleniumTestCase): def delete_custom_build(self, build_name): delete_button = None grid = self.wait_for_selector("table.grid > tbody") - for row in grid.find_elements_by_tag_name("tr"): - td = row.find_elements_by_tag_name("td") + for row in grid.find_elements(By.TAG_NAME, "tr"): + td = row.find_elements(By.TAG_NAME, "td") name = td[0].text if name == build_name: - delete_button = td[3].find_element_by_css_selector(".fa-trash-o") + delete_button = td[3].find_element(By.CSS_SELECTOR, ".fa-trash-o") break if delete_button is None: @@ -71,8 +73,8 @@ class CustomBuildsTestcase(SharedStateSeleniumTestCase): self.sleep_for(self.wait_types.UX_RENDER) builds = [] grid = self.wait_for_selector("table.grid > tbody") - for row in grid.find_elements_by_tag_name("tr"): - name = row.find_elements_by_tag_name("td")[0].text + for row in grid.find_elements(By.TAG_NAME, "tr"): + name = row.find_elements(By.TAG_NAME, "td")[0].text builds.append(name) return builds diff --git a/lib/galaxy_test/selenium/test_histories_list.py b/lib/galaxy_test/selenium/test_histories_list.py index 3bf6dd6e222..d8f0500178b 100644 --- a/lib/galaxy_test/selenium/test_histories_list.py +++ b/lib/galaxy_test/selenium/test_histories_list.py @@ -1,3 +1,5 @@ +from selenium.webdriver.common.by import By + from .framework import ( retry_assertion_during_transitions, selenium_test, @@ -214,7 +216,7 @@ class SavedHistoriesTestCase(SharedStateSeleniumTestCase): # Insert a tag tags_cell = self.get_history_tags_cell(self.history2_name) - tag_area = tags_cell.find_element_by_css_selector(".ti-new-tag-input-wrapper input") + tag_area = tags_cell.find_element(By.CSS_SELECTOR, ".ti-new-tag-input-wrapper input") tag_area.click() tag_area.send_keys(self.history2_tags[0]) self.send_enter(tag_area) @@ -223,7 +225,7 @@ class SavedHistoriesTestCase(SharedStateSeleniumTestCase): # Search by tag tags_cell = self.get_history_tags_cell(self.history2_name) - tag = tags_cell.find_element_by_css_selector(".ti-tag-center") + tag = tags_cell.find_element(By.CSS_SELECTOR, ".ti-tag-center") tag.click() self.assert_grid_histories_are([self.history2_name], False) @@ -290,8 +292,8 @@ class SavedHistoriesTestCase(SharedStateSeleniumTestCase): def get_history_tags_cell(self, history_name): tags_cell = None grid = self.wait_for_selector("#grid-table-body") - for row in grid.find_elements_by_tag_name("tr"): - td = row.find_elements_by_tag_name("td") + for row in grid.find_elements(By.TAG_NAME, "tr"): + td = row.find_elements(By.TAG_NAME, "td") if td[1].text == history_name: tags_cell = td[4] break @@ -303,9 +305,9 @@ class SavedHistoriesTestCase(SharedStateSeleniumTestCase): def check_histories(self, histories): grid = self.wait_for_selector("#grid-table-body") - for row in grid.find_elements_by_tag_name("tr"): - td = row.find_elements_by_tag_name("td") + for row in grid.find_elements(By.TAG_NAME, "tr"): + td = row.find_elements(By.TAG_NAME, "td") history_name = td[1].text if history_name in histories: - checkbox = td[0].find_element_by_tag_name("input") + checkbox = td[0].find_element(By.TAG_NAME, "input") checkbox.click() diff --git a/lib/galaxy_test/selenium/test_history_panel_collections.py b/lib/galaxy_test/selenium/test_history_panel_collections.py index cc917083643..540fe4682df 100644 --- a/lib/galaxy_test/selenium/test_history_panel_collections.py +++ b/lib/galaxy_test/selenium/test_history_panel_collections.py @@ -1,6 +1,7 @@ import time import pytest +from selenium.webdriver.common.by import By from galaxy.selenium.navigates_galaxy import WAIT_TYPES from galaxy_test.base.api_asserts import assert_status_code_is @@ -212,7 +213,7 @@ class HistoryPanelCollectionsTestCase(SeleniumTestCase): selector = ".title .name" if self.is_beta_history(): selector = ".content-title" - titles = [de.find_element_by_css_selector(selector).text for de in dataset_elements] + titles = [de.find_element(By.CSS_SELECTOR, selector).text for de in dataset_elements] assert titles == ["forward", "reverse"] self.screenshot("history_panel_collection_view_paired") @@ -237,7 +238,7 @@ class HistoryPanelCollectionsTestCase(SeleniumTestCase): selector = ".title .name" if self.is_beta_history(): selector = ".content-title" - title_elements = [de.find_element_by_css_selector(selector).text for de in dataset_elements] + title_elements = [de.find_element(By.CSS_SELECTOR, selector).text for de in dataset_elements] assert title_elements == ["data1", "data2", "data3", "data4"] check_four_datasets_shown() diff --git a/lib/galaxy_test/selenium/test_jupyter.py b/lib/galaxy_test/selenium/test_jupyter.py index b0d12c1312a..4fe7be26558 100644 --- a/lib/galaxy_test/selenium/test_jupyter.py +++ b/lib/galaxy_test/selenium/test_jupyter.py @@ -1,3 +1,5 @@ +from selenium.webdriver.common.by import By + from galaxy_test.base.populators import flakey from .framework import ( managed_history, @@ -40,7 +42,7 @@ class JupyterTestCase(SeleniumTestCase): 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") + 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: diff --git a/lib/galaxy_test/selenium/test_library_contents.py b/lib/galaxy_test/selenium/test_library_contents.py index f50ca850979..6bc793fd656 100644 --- a/lib/galaxy_test/selenium/test_library_contents.py +++ b/lib/galaxy_test/selenium/test_library_contents.py @@ -1,5 +1,6 @@ import os +from selenium.webdriver.common.by import By from selenium.webdriver.support.ui import Select from .framework import ( @@ -168,5 +169,5 @@ class LibraryContentsTestCase(SeleniumTestCase, UsesLibraryAssertions): @retry_during_transitions def _select_history_option(self, select_id, label_text): - select = Select(self.driver.find_element_by_id(select_id)) + select = Select(self.driver.find_element(By.ID, select_id)) select.select_by_visible_text(label_text) diff --git a/lib/galaxy_test/selenium/test_library_landing.py b/lib/galaxy_test/selenium/test_library_landing.py index 2f47e920e1d..cba34c23bf7 100644 --- a/lib/galaxy_test/selenium/test_library_landing.py +++ b/lib/galaxy_test/selenium/test_library_landing.py @@ -1,3 +1,5 @@ +from selenium.webdriver.common.by import By + from .framework import ( retry_assertion_during_transitions, selenium_test, @@ -86,7 +88,7 @@ class LibraryLandingTestCase(SeleniumTestCase): @retry_assertion_during_transitions def _assert_names_are(self, expected_names): - names = [e.find_element_by_css_selector("td a").text for e in self.libraries_index_table_elements()] + names = [e.find_element(By.CSS_SELECTOR, "td a").text for e in self.libraries_index_table_elements()] self.assertEqual(names, expected_names) @retry_assertion_during_transitions diff --git a/lib/galaxy_test/selenium/test_pages.py b/lib/galaxy_test/selenium/test_pages.py index 1a6f5cd3d50..2e2a6e11311 100644 --- a/lib/galaxy_test/selenium/test_pages.py +++ b/lib/galaxy_test/selenium/test_pages.py @@ -1,3 +1,5 @@ +from selenium.webdriver.common.by import By + from .framework import ( managed_history, selenium_test, @@ -31,7 +33,7 @@ class PagesTestCase(SeleniumTestCase): self.components.pages.editor.embed_dataset.wait_for_and_click() saved_datasets_element = self.components.pages.editor.dataset_selector.wait_for_and_click() self.screenshot("pages_editor_embed_dataset_dialog") - checkboxes = saved_datasets_element.find_elements_by_css_selector("input[type='checkbox']") + checkboxes = saved_datasets_element.find_elements(By.CSS_SELECTOR, "input[type='checkbox']") assert len(checkboxes) > 0 checkboxes[0].click() self.components.pages.editor.embed_dialog_add_button.wait_for_and_click() diff --git a/lib/galaxy_test/selenium/test_personal_information.py b/lib/galaxy_test/selenium/test_personal_information.py index 42a1abf0983..1f8264c2b90 100644 --- a/lib/galaxy_test/selenium/test_personal_information.py +++ b/lib/galaxy_test/selenium/test_personal_information.py @@ -1,3 +1,5 @@ +from selenium.webdriver.common.by import By + from .framework import ( selenium_test, SeleniumTestCase, @@ -18,21 +20,21 @@ class ManageInformationTestCase(SeleniumTestCase): self.navigate_to_user_preferences() self.components.preferences.manage_api_key.wait_for_and_click() self.sleep_for(self.wait_types.UX_TRANSITION) - new_key_button = self.driver.find_element_by_id("submit") - api_key_input = self.driver.find_element_by_css_selector("[data-label='Current API key:'] > input") + new_key_button = self.driver.find_element(By.ID, "submit") + api_key_input = self.driver.find_element(By.CSS_SELECTOR, "[data-label='Current API key:'] > input") # Assert that what's rendered on screen is what the API is returning self.assertEqual(api_key_input.get_property("value"), api_key) self.action_chains().move_to_element(new_key_button).click().perform() self.sleep_for(self.wait_types.UX_TRANSITION) new_api_key = self.get_api_key() - api_key_input = self.driver.find_element_by_css_selector("[data-label='Current API key:'] > input") + api_key_input = self.driver.find_element(By.CSS_SELECTOR, "[data-label='Current API key:'] > input") # And assert that this has now changed, and still renders correctly self.assertEqual(new_api_key, api_key_input.get_property("value")) @selenium_test def test_change_email(self): def assert_email(email_to_check): - self.assertTrue(email_to_check == self.driver.find_element_by_id("user-preferences-current-email").text) + self.assertTrue(email_to_check == self.driver.find_element(By.ID, "user-preferences-current-email").text) email = self._get_random_email() self.register(email) @@ -48,7 +50,7 @@ class ManageInformationTestCase(SeleniumTestCase): new_email = self._get_random_email() # new email should be different from initially registered self.assertTrue(email != new_email) - email_input_field = self.driver.find_element_by_css_selector("input[id='email']") + email_input_field = self.driver.find_element(By.CSS_SELECTOR, "input[id='email']") self.clear_input_field_and_write(email_input_field, new_email) self.components.change_user_email.submit.wait_for_and_click() @@ -62,7 +64,7 @@ class ManageInformationTestCase(SeleniumTestCase): @selenium_test def test_public_name(self): def get_name_input_field(): - return self.driver.find_element_by_css_selector("input[id='username']") + return self.driver.find_element(By.CSS_SELECTOR, "input[id='username']") def assert_public_name(expected_name): self.assertTrue(expected_name == get_name_input_field().get_attribute("value")) @@ -89,7 +91,7 @@ class ManageInformationTestCase(SeleniumTestCase): @selenium_test def test_user_address(self): def get_address_form(): - return self.driver.find_element_by_css_selector("div.ui-portlet-section > div.portlet-content") + return self.driver.find_element(By.CSS_SELECTOR, "div.ui-portlet-section > div.portlet-content") self.register(self._get_random_email()) self.navigate_to_manage_information() @@ -135,7 +137,7 @@ class ManageInformationTestCase(SeleniumTestCase): element.send_keys(new_input_text) def get_address_input_field(self, address_form, input_field_label): - return address_form.find_element_by_css_selector(f"[data-label='{input_field_label}'] > input") + return address_form.find_element(By.CSS_SELECTOR, f"[data-label='{input_field_label}'] > input") class DeleteCurrentAccountTestCase(SeleniumTestCase): diff --git a/lib/galaxy_test/selenium/test_published_histories_grid.py b/lib/galaxy_test/selenium/test_published_histories_grid.py index d4275aac3b3..ce4ec006f1c 100644 --- a/lib/galaxy_test/selenium/test_published_histories_grid.py +++ b/lib/galaxy_test/selenium/test_published_histories_grid.py @@ -1,3 +1,5 @@ +from selenium.webdriver.common.by import By + from .framework import ( retry_assertion_during_transitions, selenium_test, @@ -84,8 +86,8 @@ class HistoryGridTestCase(SharedStateSeleniumTestCase): tags = None grid = self.wait_for_selector("#grid-table-body") - for row in grid.find_elements_by_tag_name("tr"): - td = row.find_elements_by_tag_name("td") + for row in grid.find_elements(By.TAG_NAME, "tr"): + td = row.find_elements(By.TAG_NAME, "td") name = td[0].text if name == self.history1_name: tags = td[4] @@ -95,7 +97,7 @@ class HistoryGridTestCase(SharedStateSeleniumTestCase): raise AssertionError(f"Failed to find history with name [{self.history1_name}]") tag_button_selector = "div.tag-name" - tag_buttons = tags.find_elements_by_css_selector(tag_button_selector) + tag_buttons = tags.find_elements(By.CSS_SELECTOR, tag_button_selector) tag_button_text = None target_tag_button_text = self.history1_tags[0] for tag_button in tag_buttons: @@ -112,8 +114,8 @@ class HistoryGridTestCase(SharedStateSeleniumTestCase): self.sleep_for(self.wait_types.UX_RENDER) names = [] grid = self.wait_for_selector("#grid-table-body") - for row in grid.find_elements_by_tag_name("tr"): - cell = row.find_elements_by_tag_name("td")[0] # Name + for row in grid.find_elements(By.TAG_NAME, "tr"): + cell = row.find_elements(By.TAG_NAME, "td")[0] # Name names.append(cell.text) return names diff --git a/lib/galaxy_test/selenium/test_sign_out.py b/lib/galaxy_test/selenium/test_sign_out.py index d6cc6b02c30..9c953176a82 100644 --- a/lib/galaxy_test/selenium/test_sign_out.py +++ b/lib/galaxy_test/selenium/test_sign_out.py @@ -1,3 +1,5 @@ +from selenium.webdriver.common.by import By + from .framework import ( selenium_test, SeleniumTestCase, @@ -14,7 +16,7 @@ class SignOutTestCase(SeleniumTestCase): self.components.preferences.sign_out.wait_for_and_click() self.components.sign_out.cancel_button.wait_for_and_click() assert self.is_logged_in() - new_email = self.driver.find_element_by_id("user-preferences-current-email").text + new_email = self.driver.find_element(By.ID, "user-preferences-current-email").text self.assertTrue(email == new_email) self.components.preferences.sign_out.wait_for_and_click() self.components.sign_out.sign_out_button.wait_for_and_click() diff --git a/lib/galaxy_test/selenium/test_tool_form.py b/lib/galaxy_test/selenium/test_tool_form.py index d5de69193a0..3f63176bf63 100644 --- a/lib/galaxy_test/selenium/test_tool_form.py +++ b/lib/galaxy_test/selenium/test_tool_form.py @@ -1,6 +1,7 @@ import json import pytest +from selenium.webdriver.common.by import By from galaxy.model.unittest_utils.store_fixtures import one_hda_model_store_dict from galaxy.selenium.navigates_galaxy import retry_call_during_transitions @@ -65,24 +66,24 @@ class ToolFormTestCase(SeleniumTestCase, UsesHistoryItemAssertions): assert "1 : environment_variables" in generic_item.text generic_item.click() self.sleep_for(self.wait_types.UX_RENDER) - assert generic_item.find_element_by_css_selector("pre").text == "42\nmoo\nNOTTHREE" - generic_item.find_element_by_css_selector("[title='Run Job Again']").click() + assert generic_item.find_element(By.CSS_SELECTOR, "pre").text == "42\nmoo\nNOTTHREE" + generic_item.find_element(By.CSS_SELECTOR, "[title='Run Job Again']").click() self.components.tool_form.execute.wait_for_visible() @staticmethod def click_menu_item(menu, text): - for element in menu.find_elements_by_css_selector("a"): + for element in menu.find_elements(By.CSS_SELECTOR, "a"): if element.text == text: return element.click() def _table_to_key_value_elements(self, table_selector): tool_parameters_table = self.wait_for_selector_visible(table_selector) - tbody_element = tool_parameters_table.find_element_by_css_selector("tbody") - trs = tbody_element.find_elements_by_css_selector("tr") + tbody_element = tool_parameters_table.find_element(By.CSS_SELECTOR, "tbody") + trs = tbody_element.find_elements(By.CSS_SELECTOR, "tr") assert trs key_value_pairs = [] for tr in trs: - tds = tr.find_elements_by_css_selector("td") + tds = tr.find_elements(By.CSS_SELECTOR, "td") assert tds key_value_pairs.append((tds[0], tds[1])) @@ -96,7 +97,7 @@ class ToolFormTestCase(SeleniumTestCase, UsesHistoryItemAssertions): def check_recorded_val(): inttest_div_element = self.tool_parameter_div("inttest") - inttest_input_element = inttest_div_element.find_element_by_css_selector("input") + inttest_input_element = inttest_div_element.find_element(By.CSS_SELECTOR, "input") recorded_val = inttest_input_element.get_attribute("value") # Assert form re-rendered with correct value in textbox. assert recorded_val == "42", recorded_val @@ -163,8 +164,8 @@ class ToolFormTestCase(SeleniumTestCase, UsesHistoryItemAssertions): self.hda_click_details(hid) self.components.dataset_details._.wait_for_visible() tool_parameters_table = self.components.dataset_details.tool_parameters.wait_for_visible() - tbody_element = tool_parameters_table.find_element_by_css_selector("tbody") - tds = tbody_element.find_elements_by_css_selector("td") + tbody_element = tool_parameters_table.find_element(By.CSS_SELECTOR, "tbody") + tds = tbody_element.find_elements(By.CSS_SELECTOR, "td") assert tds assert any(expected_value in td.text for td in tds) diff --git a/lib/galaxy_test/selenium/test_uploads.py b/lib/galaxy_test/selenium/test_uploads.py index 64a093a7231..cda0100c616 100644 --- a/lib/galaxy_test/selenium/test_uploads.py +++ b/lib/galaxy_test/selenium/test_uploads.py @@ -1,6 +1,7 @@ import os import pytest +from selenium.webdriver.common.by import By from selenium.webdriver.common.keys import Keys from .framework import ( @@ -201,7 +202,7 @@ PRJDA60709 SAMD00016382 DRX000480 ftp.sra.ebi.ac.uk/vol1/fastq/DRR000/DRR0 rule_builder.menu_item_rule_type(rule_type="add-filter-count").wait_for_and_click() filter_editor = rule_builder.rule_editor(rule_type="add-filter-count") filter_editor_element = filter_editor.wait_for_visible() - filter_input = filter_editor_element.find_element_by_css_selector("input[type='number']") + filter_input = filter_editor_element.find_element(By.CSS_SELECTOR, "input[type='number']") filter_input.clear() filter_input.send_keys("1") self.screenshot("rules_example_1_4_filter_header") @@ -418,7 +419,7 @@ PRJDA60709 SAMD00016382 DRX000480 ftp.sra.ebi.ac.uk/vol1/fastq/DRR000/DRR0 rule_builder.menu_item_rule_type(rule_type="add-filter-count").wait_for_and_click() filter_editor = rule_builder.rule_editor(rule_type="add-filter-count") filter_editor_element = filter_editor.wait_for_visible() - filter_input = filter_editor_element.find_element_by_css_selector("input[type='number']") + filter_input = filter_editor_element.find_element(By.CSS_SELECTOR, "input[type='number']") filter_input.clear() filter_input.send_keys("1") self.screenshot("rules_deferred_datasets_4_filter_header") @@ -481,7 +482,7 @@ PRJDA60709 SAMD00016382 DRX000480 ftp.sra.ebi.ac.uk/vol1/fastq/DRR000/DRR0 def _scroll_to_end_of_table(self): rule_builder = self.components.rule_builder table_elem = rule_builder.table.wait_for_visible() - first_cell = table_elem.find_elements_by_css_selector("td")[0] + first_cell = table_elem.find_elements(By.CSS_SELECTOR, "td")[0] action_chains = self.action_chains() action_chains.move_to_element(first_cell) action_chains.click(first_cell) diff --git a/lib/galaxy_test/selenium/test_workflow_editor.py b/lib/galaxy_test/selenium/test_workflow_editor.py index b500e9ecc4c..2ab2473fe91 100644 --- a/lib/galaxy_test/selenium/test_workflow_editor.py +++ b/lib/galaxy_test/selenium/test_workflow_editor.py @@ -1,6 +1,7 @@ import json import yaml +from selenium.webdriver.common.by import By from selenium.webdriver.common.keys import Keys from galaxy_test.base.workflow_fixtures import ( @@ -651,7 +652,7 @@ steps: # 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")[4] + bookmark_td = table_elements[0].find_elements(By.TAG_NAME, "td")[4] # get bookmark pseudo element # https://stackoverflow.com/questions/45427223/click-on-pseudo-element-using-selenium @@ -671,8 +672,8 @@ steps: def workflow_editor_connect(self, source, sink, screenshot_partial=None): source_id, sink_id = self.workflow_editor_source_sink_terminal_ids(source, sink) - source_element = self.driver.find_element_by_css_selector(f"#{source_id}") - sink_element = self.driver.find_element_by_css_selector(f"#{sink_id}") + source_element = self.driver.find_element(By.CSS_SELECTOR, f"#{source_id}") + sink_element = self.driver.find_element(By.CSS_SELECTOR, f"#{sink_id}") ac = self.action_chains() ac = ac.move_to_element(source_element).click_and_hold() diff --git a/lib/galaxy_test/selenium/test_workflow_management.py b/lib/galaxy_test/selenium/test_workflow_management.py index ab4d0c6b0ba..1cf96bd8193 100644 --- a/lib/galaxy_test/selenium/test_workflow_management.py +++ b/lib/galaxy_test/selenium/test_workflow_management.py @@ -1,3 +1,5 @@ +from selenium.webdriver.common.by import By + from .framework import ( EXAMPLE_WORKFLOW_URL_1, retry_assertion_during_transitions, @@ -20,7 +22,7 @@ class WorkflowManagementTestCase(SeleniumTestCase, TestsGalaxyPagers, UsesWorkfl table_elements = self.workflow_index_table_elements() assert len(table_elements) == 1 - new_workflow = table_elements[0].find_element_by_css_selector(".workflow-dropdown") + new_workflow = table_elements[0].find_element(By.CSS_SELECTOR, ".workflow-dropdown") assert "TestWorkflow1 (imported from URL)" in new_workflow.text, new_workflow.text @selenium_test @@ -32,7 +34,7 @@ class WorkflowManagementTestCase(SeleniumTestCase, TestsGalaxyPagers, UsesWorkfl self.driver.back() self.components.workflows.external_link.wait_for_visible() # font-awesome title handling broken... https://github.com/FortAwesome/vue-fontawesome/issues/63 - # title_element = external_link_icon.find_element_by_tag_name("title") + # title_element = external_link_icon.find_element(By.TAG_NAME, "title") # assert EXAMPLE_WORKFLOW_URL_1 in title_element.text self.workflow_index_click_option("View") workflow_show = self.components.workflow_show diff --git a/lib/galaxy_test/selenium/test_workflow_run.py b/lib/galaxy_test/selenium/test_workflow_run.py index bc87a14265f..e3eac4b8d21 100644 --- a/lib/galaxy_test/selenium/test_workflow_run.py +++ b/lib/galaxy_test/selenium/test_workflow_run.py @@ -1,3 +1,5 @@ +from selenium.webdriver.common.by import By + from galaxy_test.base import rules_test_data from galaxy_test.base.workflow_fixtures import ( WORKFLOW_NESTED_REPLACEMENT_PARAMETER, @@ -137,7 +139,7 @@ steps: self.workflow_run_ensure_expanded() workflow_run = self.components.workflow_run input_div_element = workflow_run.input_div(label="input_int").wait_for_visible() - input_element = input_div_element.find_element_by_css_selector("input") + input_element = input_div_element.find_element(By.CSS_SELECTOR, "input") input_element.clear() input_element.send_keys("12345") @@ -263,7 +265,7 @@ steps: def _set_num_lines_to_3(self, element_id): # for random_lines num_lines parameter as runtime parameter in workflow form. div = self.tool_parameter_div(element_id) - input_element = div.find_element_by_css_selector("input") + input_element = div.find_element(By.CSS_SELECTOR, "input") # runtime parameters not being set to tool default value: # https://github.com/galaxyproject/galaxy/pull/7157 # initial_value = input_element.get_attribute("value") @@ -274,7 +276,7 @@ steps: def _set_replacement_parameter(self, element_id, value): # for random_lines num_lines parameter as runtime parameter in workflow form. div = self.tool_parameter_div(element_id) - input_element = div.find_element_by_css_selector("input") + input_element = div.find_element(By.CSS_SELECTOR, "input") initial_value = input_element.get_attribute("value") assert initial_value == "", initial_value input_element.clear() diff --git a/test/integration_selenium/test_admin_dependencies.py b/test/integration_selenium/test_admin_dependencies.py index f6fbc0a1ed0..880a84b01d6 100644 --- a/test/integration_selenium/test_admin_dependencies.py +++ b/test/integration_selenium/test_admin_dependencies.py @@ -1,3 +1,5 @@ +from selenium.webdriver.common.by import By + from .framework import ( selenium_test, SeleniumIntegrationTestCase, @@ -16,9 +18,9 @@ class AdminDependencyContainersTestCase(SeleniumIntegrationTestCase): admin_component.index.dependencies.wait_for_and_click() self.sleep_for(self.wait_types.UX_RENDER) # Make sure the tabs are visible - self.driver.find_element_by_link_text("Dependencies") - self.driver.find_element_by_link_text("Unused") - containers_link = self.driver.find_element_by_link_text("Containers") + self.driver.find_element(By.LINK_TEXT, "Dependencies") + self.driver.find_element(By.LINK_TEXT, "Unused") + containers_link = self.driver.find_element(By.LINK_TEXT, "Containers") # Ensure that #manage-resolver-type is visible. admin_component.manage_dependencies.resolver_type.wait_for_visible() self.screenshot("admin_dependencies_landing") diff --git a/test/integration_selenium/test_toolbox_filters.py b/test/integration_selenium/test_toolbox_filters.py index 4d1d4c17865..6bfdc7b769d 100644 --- a/test/integration_selenium/test_toolbox_filters.py +++ b/test/integration_selenium/test_toolbox_filters.py @@ -1,4 +1,5 @@ from selenium.common.exceptions import NoSuchElementException +from selenium.webdriver.common.by import By from .framework import ( selenium_test, @@ -26,7 +27,7 @@ class ToolboxFiltersSeleniumIntegrationTestCase(SeleniumIntegrationTestCase): """ self.register() # The tool panel section should be visible and clickable at this stage - section = self.driver.find_element_by_link_text("Test Section") + section = self.driver.find_element(By.LINK_TEXT, "Test Section") self.action_chains().move_to_element(section).click().perform() self.navigate_to_user_preferences() self.components.preferences.toolbox_filters.wait_for_and_click() @@ -41,4 +42,4 @@ class ToolboxFiltersSeleniumIntegrationTestCase(SeleniumIntegrationTestCase): self.sleep_for(self.wait_types.UX_RENDER) self.home() # But now it should raise NoSuchElementException - self.assertRaises(NoSuchElementException, lambda: self.driver.find_element_by_link_text("Test Section")) + self.assertRaises(NoSuchElementException, lambda: self.driver.find_element(By.LINK_TEXT, "Test Section"))