From af2fd368156439b79e4c1eb2278c433246771e44 Mon Sep 17 00:00:00 2001 From: Sarah Boyce <42296566+sarahboyce@users.noreply.github.com> Date: Tue, 28 Nov 2023 09:41:39 +0100 Subject: Refs #34995 -- Made Selenium tests more robust for admin_views and admin_widgets suites. Depending on screen sizes, the selenium tests that would "click" or interact with an element outside the scope of the visible window would produce test failures (raising ElementNotInteractableException in CI runs). This branch switches those to using ActionChains, which ensures that the click (or other interaction) is performed only after successfully completing the move to the relevant element. Co-authored-by: Tom Carrick --- tests/admin_widgets/tests.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'tests/admin_widgets') diff --git a/tests/admin_widgets/tests.py b/tests/admin_widgets/tests.py index da0d194660..d497599435 100644 --- a/tests/admin_widgets/tests.py +++ b/tests/admin_widgets/tests.py @@ -1717,13 +1717,15 @@ class AdminRawIdWidgetSeleniumTests(AdminWidgetSeleniumTestCase): class RelatedFieldWidgetSeleniumTests(AdminWidgetSeleniumTestCase): def test_ForeignKey_using_to_field(self): + from selenium.webdriver import ActionChains from selenium.webdriver.common.by import By from selenium.webdriver.support.ui import Select self.admin_login(username="super", password="secret", login_url="/") - self.selenium.get( - self.live_server_url + reverse("admin:admin_widgets_profile_add") - ) + with self.wait_page_loaded(): + self.selenium.get( + self.live_server_url + reverse("admin:admin_widgets_profile_add") + ) main_window = self.selenium.current_window_handle # Click the Add User button to add new @@ -1769,7 +1771,8 @@ class RelatedFieldWidgetSeleniumTests(AdminWidgetSeleniumTestCase): By.CSS_SELECTOR, "#id_user option[value=changednewuser]" ) - self.selenium.find_element(By.ID, "view_id_user").click() + element = self.selenium.find_element(By.ID, "view_id_user") + ActionChains(self.selenium).move_to_element(element).click(element).perform() self.wait_for_value("#id_username", "changednewuser") self.selenium.back() -- cgit v1.3