diff options
| author | Patryk Bratkowski <151854505+pbratkowski@users.noreply.github.com> | 2023-11-30 14:35:16 +0200 |
|---|---|---|
| committer | Jacob Walls <jacobtylerwalls@gmail.com> | 2026-02-02 14:53:30 -0500 |
| commit | 5798f4bb1750f68d3bfbaa75020db7fa02b4db15 (patch) | |
| tree | 210556120665e37e0b0b00edbf986f3ec5266940 /tests/admin_views | |
| parent | d725f6856d7488ba2a397dfe47dd851420188159 (diff) | |
Fixed selenium tests in Firefox.
Unlike Chromium-based browsers, Firefox does not automatically scroll
elements into view when using the Actions API with move_to_element.
This calls the scrollIntoView function explicitly, which fixes
some selenium tests when not running in headless mode.
Diffstat (limited to 'tests/admin_views')
| -rw-r--r-- | tests/admin_views/tests.py | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/tests/admin_views/tests.py b/tests/admin_views/tests.py index 0ff3839745..95be0ed89d 100644 --- a/tests/admin_views/tests.py +++ b/tests/admin_views/tests.py @@ -6101,6 +6101,9 @@ class SeleniumTests(AdminSeleniumTestCase): status = self.selenium.find_element( By.ID, "id_relatedprepopulated_set-2-0-status" ) + # Fix for Firefox which does not scroll to clicked elements automatically with + # the Options API + self.selenium.execute_script("arguments[0].scrollIntoView();", status) ActionChains(self.selenium).move_to_element(status).click(status).perform() self.selenium.find_element( By.ID, "id_relatedprepopulated_set-2-0-pubdate" @@ -6135,6 +6138,7 @@ class SeleniumTests(AdminSeleniumTestCase): status = self.selenium.find_element( By.ID, "id_relatedprepopulated_set-2-1-status" ) + self.selenium.execute_script("arguments[0].scrollIntoView();", status) ActionChains(self.selenium).move_to_element(status).click(status).perform() self.select_option("#id_relatedprepopulated_set-2-1-status", "option one") self.selenium.find_element( @@ -6163,6 +6167,7 @@ class SeleniumTests(AdminSeleniumTestCase): row_id = "id_relatedprepopulated_set-4-0-" self.selenium.find_element(By.ID, f"{row_id}pubdate").send_keys("2011-12-12") status = self.selenium.find_element(By.ID, f"{row_id}status") + self.selenium.execute_script("arguments[0].scrollIntoView();", status) ActionChains(self.selenium).move_to_element(status).click(status).perform() self.select_option(f"#{row_id}status", "option one") self.selenium.find_element(By.ID, f"{row_id}name").send_keys( @@ -6177,13 +6182,16 @@ class SeleniumTests(AdminSeleniumTestCase): self.assertEqual(slug1, "stacked-inline-2011-12-12") self.assertEqual(slug2, "option-one") # Add inline. - self.selenium.find_elements( + add_link = self.selenium.find_elements( By.LINK_TEXT, "Add another Related prepopulated", - )[3].click() + )[3] + self.selenium.execute_script("arguments[0].scrollIntoView();", add_link) + add_link.click() row_id = "id_relatedprepopulated_set-4-1-" self.selenium.find_element(By.ID, f"{row_id}pubdate").send_keys("1999-01-20") status = self.selenium.find_element(By.ID, f"{row_id}status") + self.selenium.execute_script("arguments[0].scrollIntoView();", status) ActionChains(self.selenium).move_to_element(status).click(status).perform() self.select_option(f"#{row_id}status", "option two") self.selenium.find_element(By.ID, f"{row_id}name").send_keys( |
