1
0
mirror of https://github.com/django/django.git synced 2025-10-24 14:16:09 +00:00

[5.0.x] 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>

Backport of af2fd36815 from main
This commit is contained in:
Sarah Boyce
2023-11-28 09:41:39 +01:00
committed by Natalia
parent 7f1dc67f53
commit 9fe12b0f36
2 changed files with 25 additions and 11 deletions

View File

@@ -1713,13 +1713,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
@@ -1765,7 +1767,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()