From c4c66aa73d226dd657fbc3d2a7e3a8bf309f7d31 Mon Sep 17 00:00:00 2001 From: Hrushikesh Vaidya Date: Mon, 14 Oct 2024 05:04:31 +0530 Subject: [PATCH] Apply suggestions from code review Co-authored-by: Sarah Boyce <42296566+sarahboyce@users.noreply.github.com> --- tests/admin_views/tests.py | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) 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):