diff options
| author | Sarah Boyce <42296566+sarahboyce@users.noreply.github.com> | 2023-11-28 09:41:39 +0100 |
|---|---|---|
| committer | Natalia <124304+nessita@users.noreply.github.com> | 2023-11-30 10:39:10 -0300 |
| commit | af2fd368156439b79e4c1eb2278c433246771e44 (patch) | |
| tree | 7445edd1ec11b640e028610850cdd683c04fb141 /tests/admin_widgets | |
| parent | b34a4771a3d4cd7829a1f38a0f6a7a0da519a724 (diff) | |
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 <tom@carrick.eu>
Diffstat (limited to 'tests/admin_widgets')
| -rw-r--r-- | tests/admin_widgets/tests.py | 11 |
1 files changed, 7 insertions, 4 deletions
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() |
