diff --git a/tests/admin_views/tests.py b/tests/admin_views/tests.py index 43ef7f92e7..9ec38e45ec 100644 --- a/tests/admin_views/tests.py +++ b/tests/admin_views/tests.py @@ -6207,19 +6207,22 @@ class SeleniumTests(AdminSeleniumTestCase): self.take_screenshot("focus-multi-widget") @screenshot_cases(["desktop_size", "mobile_size", "rtl", "dark", "high_contrast"]) - def test_error_message_position(self): - """Error messages are shown above the field and below the label""" + def test_error_message(self): from selenium.webdriver.common.by import By - url = reverse("admin:admin_views_article_add") - full_url = self.live_server_url + url self.admin_login( username="super", password="secret", login_url=reverse("admin:index") ) - self.selenium.get(full_url) - # Submit an empty form to trigger validation errors - self.selenium.find_element(By.CSS_SELECTOR, 'input[type="submit"]').click() - self.wait_page_ready() + with self.wait_page_loaded(): + self.selenium.get( + self.live_server_url + reverse("admin:admin_views_picture_add") + ) + + # Submit an empty form to trigger validation errors. + with self.wait_page_loaded(): + self.selenium.find_element(By.CSS_SELECTOR, 'input[type="submit"]').click() + error = self.selenium.find_elements(By.CSS_SELECTOR, ".errornote") + self.assertEqual(len(error), 1) self.take_screenshot("error-message-position") def test_cancel_delete_confirmation(self):