-
-
Notifications
You must be signed in to change notification settings - Fork 251
[tests] Selenium test for Preview configuration with keyboard #868 #955
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
6607106
0b2c0e8
937f2f2
ade1905
28eee54
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -6,8 +6,10 @@ | |||||||||||||||||||||||
| TimeoutException, | ||||||||||||||||||||||||
| UnexpectedAlertPresentException, | ||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||
| from selenium.webdriver.common.action_chains import ActionChains | ||||||||||||||||||||||||
| from selenium.webdriver.common.alert import Alert | ||||||||||||||||||||||||
| from selenium.webdriver.common.by import By | ||||||||||||||||||||||||
| from selenium.webdriver.common.keys import Keys | ||||||||||||||||||||||||
| from selenium.webdriver.support import expected_conditions as EC | ||||||||||||||||||||||||
| from selenium.webdriver.support.ui import Select, WebDriverWait | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
|
|
@@ -130,6 +132,48 @@ def test_create_new_device(self): | |||||||||||||||||||||||
| 'The Device “11:22:33:44:55:66” was added successfully.', | ||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| def test_device_preview_keyboard_shortcuts(self): | ||||||||||||||||||||||||
| self._create_config(device=self._create_device(name='Test')) | ||||||||||||||||||||||||
| self.login() | ||||||||||||||||||||||||
| self.open(reverse('admin:config_device_changelist')) | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| # open first device in the list | ||||||||||||||||||||||||
| self.web_driver.find_element( | ||||||||||||||||||||||||
| by=By.CSS_SELECTOR, value='tbody tr:nth-child(1) th a' | ||||||||||||||||||||||||
| ).click() | ||||||||||||||||||||||||
| try: | ||||||||||||||||||||||||
| WebDriverWait(self.web_driver, 2).until( | ||||||||||||||||||||||||
| EC.presence_of_element_located((By.CSS_SELECTOR, '#content-main')) | ||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||
| except TimeoutException: | ||||||||||||||||||||||||
| self.fail('Device detail page did not load in time') | ||||||||||||||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The |
||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| with self.subTest('press ALT + P and expect overlay to be shown'): | ||||||||||||||||||||||||
| actions = ActionChains(self.web_driver) | ||||||||||||||||||||||||
| actions.key_down(Keys.ALT).send_keys('p').key_up(Keys.ALT).perform() | ||||||||||||||||||||||||
| try: | ||||||||||||||||||||||||
| WebDriverWait(self.web_driver, 2).until( | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
| WebDriverWait(self.web_driver, 2).until( | |
| WebDriverWait(self.web_driver, 1).until( |
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's use EC.visibility_of_element_located
| WebDriverWait(self.web_driver, 2).until( | |
| lambda driver: driver.find_element( | |
| By.CSS_SELECTOR, '.djnjc-overlay:not(.loading)' | |
| ).value_of_css_property('display') | |
| != 'none' | |
| ) | |
| WebDriverWait(self.web_driver, 2).until( | |
| EC.visibility_of_element_located( | |
| (By.CSS_SELECTOR, '.djnjc-overlay:not(.loading)') | |
| ) | |
| ) |
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| WebDriverWait(self.web_driver, 2).until( | |
| WebDriverWait(self.web_driver, 1).until( |
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similarly, this can be changed to use EC.invisibility_of_element_located
| WebDriverWait(self.web_driver, 2).until( | |
| lambda driver: driver.find_element( | |
| By.CSS_SELECTOR, '.djnjc-overlay:not(.loading)' | |
| ).value_of_css_property('display') | |
| == 'none' | |
| ) | |
| WebDriverWait(self.web_driver, 2).until( | |
| EC.invisibility_of_element_located( | |
| (By.CSS_SELECTOR, '.djnjc-overlay:not(.loading)') | |
| ) | |
| ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be shortened by directly opening the device page.