(self)
| 6705 | |
| 6706 | @screenshot_cases(["desktop_size", "mobile_size", "rtl", "dark", "high_contrast"]) |
| 6707 | def test_selectbox_selected_rows(self): |
| 6708 | from selenium.webdriver import ActionChains |
| 6709 | from selenium.webdriver.common.by import By |
| 6710 | from selenium.webdriver.common.keys import Keys |
| 6711 | |
| 6712 | self.admin_login( |
| 6713 | username="super", password="secret", login_url=reverse("admin:index") |
| 6714 | ) |
| 6715 | # Create a new user to ensure that no extra permissions have been set. |
| 6716 | user = User.objects.create_user(username="new", password="newuser") |
| 6717 | url = self.live_server_url + reverse("admin:auth_user_change", args=[user.id]) |
| 6718 | self.selenium.get(url) |
| 6719 | self.trigger_resize() |
| 6720 | |
| 6721 | # Scroll to the User permissions section. |
| 6722 | user_permissions = self.selenium.find_element( |
| 6723 | By.CSS_SELECTOR, "#id_user_permissions_from" |
| 6724 | ) |
| 6725 | ActionChains(self.selenium).move_to_element(user_permissions).perform() |
| 6726 | self.take_screenshot("selectbox-available-perms-none-selected") |
| 6727 | |
| 6728 | # Select multiple permissions from the "Available" list. |
| 6729 | ct = ContentType.objects.get_for_model(Permission) |
| 6730 | perms = list(Permission.objects.filter(content_type=ct)) |
| 6731 | for perm in perms: |
| 6732 | elem = self.selenium.find_element( |
| 6733 | By.CSS_SELECTOR, f"#id_user_permissions_from option[value='{perm.id}']" |
| 6734 | ) |
| 6735 | ActionChains(self.selenium).key_down(self.modifier_key).click(elem).key_up( |
| 6736 | self.modifier_key |
| 6737 | ).perform() |
| 6738 | |
| 6739 | # Move focus to other element. |
| 6740 | self.selenium.find_element( |
| 6741 | By.CSS_SELECTOR, "#id_user_permissions_input" |
| 6742 | ).click() |
| 6743 | self.take_screenshot("selectbox-available-perms-some-selected") |
| 6744 | |
| 6745 | # Move permissions to the "Chosen" list, but none is selected yet. |
| 6746 | self.selenium.find_element(By.CSS_SELECTOR, "#id_user_permissions_add").click() |
| 6747 | self.take_screenshot("selectbox-chosen-perms-none-selected") |
| 6748 | |
| 6749 | # Select some permissions from the "Chosen" list. |
| 6750 | for perm in [perms[0], perms[-1]]: |
| 6751 | elem = self.selenium.find_element( |
| 6752 | By.CSS_SELECTOR, f"#id_user_permissions_to option[value='{perm.id}']" |
| 6753 | ) |
| 6754 | ActionChains(self.selenium).key_down(self.modifier_key).click(elem).key_up( |
| 6755 | self.modifier_key |
| 6756 | ).perform() |
| 6757 | |
| 6758 | # Move focus to other element. |
| 6759 | body = self.selenium.find_element(By.TAG_NAME, "body") |
| 6760 | body.send_keys(Keys.TAB) |
| 6761 | self.take_screenshot("selectbox-chosen-perms-some-selected") |
| 6762 | |
| 6763 | @screenshot_cases(["desktop_size", "mobile_size", "rtl", "dark", "high_contrast"]) |
| 6764 | def test_first_field_focus(self): |
nothing calls this directly
no test coverage detected