From a3adeab0346b3965c347f061018cd109fd538cd0 Mon Sep 17 00:00:00 2001 From: John Chilton Date: Thu, 16 Oct 2025 09:55:32 -0400 Subject: [PATCH] Update tests for new abstractions... --- lib/galaxy/selenium/navigates_galaxy.py | 11 ++++++--- .../selenium/test_collection_edit.py | 2 +- .../test_history_panel_collections.py | 6 +++-- .../selenium/test_library_landing.py | 4 +++- lib/galaxy_test/selenium/test_pages_index.py | 7 +----- .../selenium/test_personal_information.py | 6 ++--- lib/galaxy_test/selenium/test_registration.py | 4 +--- lib/galaxy_test/selenium/test_uploads.py | 16 ++++++------- .../selenium/test_workflow_editor.py | 24 ++++++++++++------- 9 files changed, 44 insertions(+), 36 deletions(-) diff --git a/lib/galaxy/selenium/navigates_galaxy.py b/lib/galaxy/selenium/navigates_galaxy.py index c6609356aa1..c2e53f02309 100644 --- a/lib/galaxy/selenium/navigates_galaxy.py +++ b/lib/galaxy/selenium/navigates_galaxy.py @@ -1771,9 +1771,14 @@ class NavigatesGalaxy(HasDriverProxy[WaitType]): self.wait_for_selector_absent_or_hidden(".toast", wait_type=WAIT_TYPES.UX_POPUP) def clear_tooltips(self, selector_to_move="#center"): - action_chains = self.action_chains() - center_element = self.find_element_by_selector(selector_to_move) - action_chains.move_to_element(center_element).perform() + if self.backend_type == "selenium": + action_chains = self.action_chains() + center_element = self.find_element_by_selector(selector_to_move) + action_chains.move_to_element(center_element).perform() + else: + page = self.page + center_element = page.locator(selector_to_move) + center_element.hover() self.wait_for_selector_absent_or_hidden(".b-tooltip", wait_type=WAIT_TYPES.UX_POPUP) def pages_index_table_elements(self): diff --git a/lib/galaxy_test/selenium/test_collection_edit.py b/lib/galaxy_test/selenium/test_collection_edit.py index 5824e77c811..4f3e8d4e589 100644 --- a/lib/galaxy_test/selenium/test_collection_edit.py +++ b/lib/galaxy_test/selenium/test_collection_edit.py @@ -53,7 +53,7 @@ class TestCollectionEdit(SeleniumTestCase): self.history_panel_ensure_showing_item_details(1) item = self.history_panel_item_component(hid=1) item.datatype.wait_for_visible() - self._wait_on(lambda _: item.datatype.wait_for_text() == dataNew) + self._wait_on(lambda *_: item.datatype.wait_for_text() == dataNew) def _create_simple_list_collection(self, filename, ext): self.perform_upload(self.get_filename(filename), ext=ext) diff --git a/lib/galaxy_test/selenium/test_history_panel_collections.py b/lib/galaxy_test/selenium/test_history_panel_collections.py index 723957b4b42..c16e1f4827d 100644 --- a/lib/galaxy_test/selenium/test_history_panel_collections.py +++ b/lib/galaxy_test/selenium/test_history_panel_collections.py @@ -1,5 +1,7 @@ import time +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 from galaxy_test.base.populators import flakey @@ -211,7 +213,7 @@ class TestHistoryPanelCollections(SeleniumTestCase): assert len(dataset_elements) == 2, dataset_elements selector = ".title .name" selector = ".content-title" - titles = [de.find_element(self.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") @@ -232,7 +234,7 @@ class TestHistoryPanelCollections(SeleniumTestCase): assert len(dataset_elements) == 4, dataset_elements selector = ".title .name" selector = ".content-title" - title_elements = [de.find_element(self.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_library_landing.py b/lib/galaxy_test/selenium/test_library_landing.py index 51b305bdd71..8161cedcc95 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_only, @@ -89,7 +91,7 @@ class TestLibraryLanding(SeleniumTestCase): @retry_assertion_during_transitions def _assert_names_are(self, expected_names): - names = [e.find_element(self.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()] assert names == expected_names @retry_assertion_during_transitions diff --git a/lib/galaxy_test/selenium/test_pages_index.py b/lib/galaxy_test/selenium/test_pages_index.py index 4f19a04fe93..3718bbae39a 100644 --- a/lib/galaxy_test/selenium/test_pages_index.py +++ b/lib/galaxy_test/selenium/test_pages_index.py @@ -14,13 +14,8 @@ class TestPagesIndex(SeleniumTestCase): page_title = page_response["title"] self.navigate_to_pages() self._assert_showing_n_pages(1) - if self.backend_type == "selenium": + with self.accept_alert(): self.select_grid_operation(page_title, "Delete") - self.accept_alert() - else: - self._driver_impl.page.on("dialog", lambda dialog: dialog.accept()) - self.select_grid_operation(page_title, "Delete") - self.sleep_for(self.wait_types.UX_TRANSITION) self._assert_showing_n_pages(0) diff --git a/lib/galaxy_test/selenium/test_personal_information.py b/lib/galaxy_test/selenium/test_personal_information.py index 962812219f3..853209b1041 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 galaxy_test.selenium.framework import ( selenium_only, selenium_test, @@ -139,9 +141,7 @@ class TestManageInformation(SeleniumTestCase): element.send_keys(new_input_text) def get_address_input_field(self, address_form, input_field_label): - return address_form.find_element( - self.by.CSS_SELECTOR, f"[data-label='{input_field_label}'] > div > div > input" - ) + return address_form.find_element(By.CSS_SELECTOR, f"[data-label='{input_field_label}'] > div > div > input") class TestDeleteCurrentAccount(SeleniumTestCase): diff --git a/lib/galaxy_test/selenium/test_registration.py b/lib/galaxy_test/selenium/test_registration.py index 50e8cf91471..b65cf646350 100644 --- a/lib/galaxy_test/selenium/test_registration.py +++ b/lib/galaxy_test/selenium/test_registration.py @@ -1,17 +1,15 @@ from .framework import ( - selenium_only, selenium_test, SeleniumTestCase, ) class TestRegistration(SeleniumTestCase): - @selenium_only("title abstraction not yet implemented") @selenium_test def test_landing(self): # loading galaxy homepage self.home() - assert self.driver.title == "Galaxy", self.driver.title + assert self.page_title == "Galaxy", self.page_title self.components.masthead._.wait_for_visible() @selenium_test diff --git a/lib/galaxy_test/selenium/test_uploads.py b/lib/galaxy_test/selenium/test_uploads.py index 34a11761c77..67fb8ad84c8 100644 --- a/lib/galaxy_test/selenium/test_uploads.py +++ b/lib/galaxy_test/selenium/test_uploads.py @@ -1,6 +1,8 @@ import os import pytest +from selenium.webdriver.common.by import By +from selenium.webdriver.common.keys import Keys from .framework import ( selenium_only, @@ -55,9 +57,7 @@ class TestUploads(SeleniumTestCase, UsesHistoryItemAssertions): self.history_panel_click_item_title(hid=1, wait=True) self.history_panel_item_view_dataset_details(1) - param_values = self.driver.find_element( - self.by.CSS_SELECTOR, "#tool-parameters td.tool-parameter-value .vjs-tree" - ) + param_values = self.driver.find_element(By.CSS_SELECTOR, "#tool-parameters td.tool-parameter-value .vjs-tree") request_json = param_values.get_attribute("data-request-json") assert request_json for data in paste_content: @@ -254,7 +254,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(self.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") @@ -476,7 +476,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(self.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") @@ -541,14 +541,14 @@ PRJDA60709 SAMD00016382 DRX000480 ftp.sra.ebi.ac.uk/vol1/fastq/DRR000/DRR0 rule_builder = self.components.rule_builder table_elem = rule_builder.table.wait_for_visible() # handsontable - # first_cell = table_elem.find_elements(self.by.CSS_SELECTOR, "td")[0] + # first_cell = table_elem.find_elements(By.CSS_SELECTOR, "td")[0] # aggrid - first_cell = table_elem.find_elements(self.by.CSS_SELECTOR, ".ag-cell")[0] + first_cell = table_elem.find_elements(By.CSS_SELECTOR, ".ag-cell")[0] action_chains = self.action_chains() action_chains.move_to_element(first_cell) action_chains.click(first_cell) for _ in range(15): - action_chains.send_keys(self.keys.ARROW_RIGHT) + action_chains.send_keys(Keys.ARROW_RIGHT) action_chains.perform() def _setup_uniprot_example(self): diff --git a/lib/galaxy_test/selenium/test_workflow_editor.py b/lib/galaxy_test/selenium/test_workflow_editor.py index bbbf30a3d6c..2bcfbe60ebb 100644 --- a/lib/galaxy_test/selenium/test_workflow_editor.py +++ b/lib/galaxy_test/selenium/test_workflow_editor.py @@ -1,5 +1,8 @@ import json -from typing import Optional +from typing import ( + cast, + Optional, +) import pytest import yaml @@ -9,6 +12,7 @@ from selenium.webdriver.common.keys import Keys from selenium.webdriver.remote.webelement import WebElement from galaxy.selenium.navigates_galaxy import ColumnDefinition +from galaxy.selenium.web_element_protocol import WebElementProtocol from galaxy_test.base.workflow_fixtures import ( WORKFLOW_NESTED_SIMPLE, WORKFLOW_OPTIONAL_TRUE_INPUT_COLLECTION, @@ -1381,7 +1385,7 @@ steps: self.action_chains().send_keys("Hello World").perform() # check if all options were applied - comment_content: WebElement = editor.comment.text_inner.wait_for_visible() + comment_content: WebElementProtocol = editor.comment.text_inner.wait_for_visible() assert comment_content.text == "Hello World" comment_content_class = comment_content.get_attribute("class") assert comment_content_class @@ -1406,7 +1410,7 @@ steps: editor.tool_bar.tool(tool="pointer").wait_for_and_click() - markdown_comment_content: WebElement = editor.comment.markdown_rendered.wait_for_visible() + markdown_comment_content: WebElementProtocol = editor.comment.markdown_rendered.wait_for_visible() assert markdown_comment_content.text == "Hello World" assert markdown_comment_content.find_element(By.TAG_NAME, "h2") is not None @@ -1425,7 +1429,7 @@ steps: self.mouse_drag(from_element=canvas, from_offset=(-200, -150), to_offset=(400, 300)) self.action_chains().send_keys("My Frame").perform() - title: WebElement = editor.comment.frame_title.wait_for_visible() + title: WebElementProtocol = editor.comment.frame_title.wait_for_visible() assert title.text == "My Frame" width, height = self.get_element_size(editor.comment._.wait_for_visible()) @@ -1466,7 +1470,7 @@ steps: self.mouse_drag(from_element=canvas, from_offset=(-100, -100), to_offset=(200, 200)) - freehand_comment_a: WebElement = editor.comment.freehand_comment.wait_for_visible() + freehand_comment_a: WebElementProtocol = editor.comment.freehand_comment.wait_for_visible() # delete by clicking editor.tool_bar.tool(tool="freehand_eraser").wait_for_and_click() @@ -1480,7 +1484,7 @@ steps: self.mouse_drag(from_element=canvas, from_offset=(-100, -100), to_offset=(200, 200)) - freehand_comment_b: WebElement = editor.comment.freehand_comment.wait_for_visible() + freehand_comment_b: WebElementProtocol = editor.comment.freehand_comment.wait_for_visible() editor.tool_bar.tool(tool="freehand_eraser").wait_for_and_click() self.mouse_drag( @@ -1622,7 +1626,7 @@ steps: return self.get_element_position(node) - def get_element_position(self, element: WebElement): + def get_element_position(self, element: WebElementProtocol): left = element.value_of_css_property("left") top = element.value_of_css_property("top") @@ -1631,7 +1635,7 @@ steps: return (int(left_stripped), int(top_stripped)) - def get_element_size(self, element: WebElement): + def get_element_size(self, element: WebElementProtocol): width = element.value_of_css_property("width") height = element.value_of_css_property("height") @@ -1741,6 +1745,8 @@ steps: assert expected_text in text, f"Failed to find expected text [{expected_text}] in modal text [{text}]" def move_center_of_canvas(self, xoffset=0, yoffset=0): - canvas = self.find_element_by_id("canvas-container") + _canvas = self.find_element_by_id("canvas-container") + assert self.backend_type == "selenium" + canvas = cast(WebElement, _canvas) chains = ActionChains(self.driver) chains.click_and_hold(canvas).move_by_offset(xoffset=xoffset, yoffset=yoffset).release().perform()