mirror of https://github.com/django/django.git
Refs #33029 -- Fixed popups Selenium tests in headless mode.
Co-authored-by: Yash Jhunjhunwala <yash@jhunjhunwalaadvisors.com>
This commit is contained in:
parent
1c802ca2a9
commit
402ae37873
|
@ -4649,6 +4649,8 @@ class SeleniumTests(AdminSeleniumTestCase):
|
|||
|
||||
# Tabular inlines ----------------------------------------------------
|
||||
# Initial inline
|
||||
element = self.selenium.find_element_by_id('id_relatedprepopulated_set-2-0-status')
|
||||
self.selenium.execute_script('window.scrollTo(0, %s);' % element.location['y'])
|
||||
self.selenium.find_element_by_id('id_relatedprepopulated_set-2-0-pubdate').send_keys('1234-12-07')
|
||||
self.select_option('#id_relatedprepopulated_set-2-0-status', 'option two')
|
||||
self.selenium.find_element_by_id('id_relatedprepopulated_set-2-0-name').send_keys(
|
||||
|
@ -4992,32 +4994,35 @@ class SeleniumTests(AdminSeleniumTestCase):
|
|||
add_url = reverse('admin:admin_views_box_add', current_app=site.name)
|
||||
self.selenium.get(self.live_server_url + add_url)
|
||||
|
||||
base_window = self.selenium.current_window_handle
|
||||
self.selenium.find_element_by_id('add_id_next_box').click()
|
||||
self.wait_for_and_switch_to_popup()
|
||||
|
||||
popup_window_test = self.selenium.current_window_handle
|
||||
self.selenium.find_element_by_id('id_title').send_keys('test')
|
||||
self.selenium.find_element_by_id('add_id_next_box').click()
|
||||
self.wait_for_and_switch_to_popup(num_windows=3)
|
||||
|
||||
popup_window_test2 = self.selenium.current_window_handle
|
||||
self.selenium.find_element_by_id('id_title').send_keys('test2')
|
||||
self.selenium.find_element_by_id('add_id_next_box').click()
|
||||
self.wait_for_and_switch_to_popup(num_windows=4)
|
||||
|
||||
self.selenium.find_element_by_id('id_title').send_keys('test3')
|
||||
self.selenium.find_element_by_xpath('//input[@value="Save"]').click()
|
||||
self.selenium.switch_to.window(self.selenium.window_handles[-1])
|
||||
self.selenium.switch_to.window(popup_window_test2)
|
||||
select = Select(self.selenium.find_element_by_id('id_next_box'))
|
||||
next_box_id = str(Box.objects.get(title="test3").id)
|
||||
self.assertEqual(select.first_selected_option.get_attribute('value'), next_box_id)
|
||||
|
||||
self.selenium.find_element_by_xpath('//input[@value="Save"]').click()
|
||||
self.selenium.switch_to.window(self.selenium.window_handles[-1])
|
||||
self.selenium.switch_to.window(popup_window_test)
|
||||
select = Select(self.selenium.find_element_by_id('id_next_box'))
|
||||
next_box_id = str(Box.objects.get(title="test2").id)
|
||||
self.assertEqual(select.first_selected_option.get_attribute('value'), next_box_id)
|
||||
|
||||
self.selenium.find_element_by_xpath('//input[@value="Save"]').click()
|
||||
self.selenium.switch_to.window(self.selenium.window_handles[-1])
|
||||
self.selenium.switch_to.window(base_window)
|
||||
select = Select(self.selenium.find_element_by_id('id_next_box'))
|
||||
next_box_id = str(Box.objects.get(title="test").id)
|
||||
self.assertEqual(select.first_selected_option.get_attribute('value'), next_box_id)
|
||||
|
@ -5046,11 +5051,13 @@ class SeleniumTests(AdminSeleniumTestCase):
|
|||
|
||||
self.selenium.switch_to.window(test2_window)
|
||||
self.selenium.find_element_by_xpath('//input[@value="Save"]').click()
|
||||
self.wait_until(lambda d: len(d.window_handles) == 2, 1)
|
||||
self.assertEqual(len(self.selenium.window_handles), 2)
|
||||
|
||||
# Close final popup to clean up test.
|
||||
self.selenium.switch_to.window(test_window)
|
||||
self.selenium.find_element_by_xpath('//input[@value="Save"]').click()
|
||||
self.wait_until(lambda d: len(d.window_handles) == 1, 1)
|
||||
self.selenium.switch_to.window(self.selenium.window_handles[-1])
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue