Fixed #31042 -- Removed AdminSeleniumTestCase.get_css_value() in favor of Selenium .is_displayed().

All instances of AdminSeleniumTestCase.get_css_value() were used to
inspect the display property.
This commit is contained in:
Jon Dufresne 2019-11-28 06:10:13 -08:00 committed by Carlton Gibson
parent 875e3ff4fd
commit c8bd37a860
2 changed files with 8 additions and 16 deletions

View File

@ -133,14 +133,6 @@ class AdminSeleniumTestCase(SeleniumTestCase, StaticLiveServerTestCase):
with self.wait_page_loaded():
self.selenium.find_element_by_xpath('//input[@value="%s"]' % login_text).click()
def get_css_value(self, selector, attribute):
"""
Return the value for the CSS attribute of a DOM element specified by
the given selector. Uses the jQuery that ships with Django.
"""
return self.selenium.execute_script(
'return django.jQuery("%s").css("%s")' % (selector, attribute))
def select_option(self, selector, value):
"""
Select the <OPTION> with the value `value` inside the <SELECT> widget

View File

@ -743,19 +743,19 @@ class DateTimePickerSeleniumTests(AdminWidgetSeleniumTestCase):
# First, with the date picker widget ---------------------------------
cal_icon = self.selenium.find_element_by_id('calendarlink0')
# The date picker is hidden
self.assertEqual(self.get_css_value('#calendarbox0', 'display'), 'none')
self.assertFalse(self.selenium.find_element_by_id('calendarbox0').is_displayed())
# Click the calendar icon
cal_icon.click()
# The date picker is visible
self.assertEqual(self.get_css_value('#calendarbox0', 'display'), 'block')
self.assertTrue(self.selenium.find_element_by_id('calendarbox0').is_displayed())
# Press the ESC key
self.selenium.find_element_by_tag_name('body').send_keys([Keys.ESCAPE])
# The date picker is hidden again
self.assertEqual(self.get_css_value('#calendarbox0', 'display'), 'none')
self.assertFalse(self.selenium.find_element_by_id('calendarbox0').is_displayed())
# Click the calendar icon, then on the 15th of current month
cal_icon.click()
self.selenium.find_element_by_xpath("//a[contains(text(), '15')]").click()
self.assertEqual(self.get_css_value('#calendarbox0', 'display'), 'none')
self.assertFalse(self.selenium.find_element_by_id('calendarbox0').is_displayed())
self.assertEqual(
self.selenium.find_element_by_id('id_birthdate_0').get_attribute('value'),
datetime.today().strftime('%Y-%m-') + '15',
@ -764,11 +764,11 @@ class DateTimePickerSeleniumTests(AdminWidgetSeleniumTestCase):
# Then, with the time picker widget ----------------------------------
time_icon = self.selenium.find_element_by_id('clocklink0')
# The time picker is hidden
self.assertEqual(self.get_css_value('#clockbox0', 'display'), 'none')
self.assertFalse(self.selenium.find_element_by_id('clockbox0').is_displayed())
# Click the time icon
time_icon.click()
# The time picker is visible
self.assertEqual(self.get_css_value('#clockbox0', 'display'), 'block')
self.assertTrue(self.selenium.find_element_by_id('clockbox0').is_displayed())
self.assertEqual(
[
x.text for x in
@ -779,11 +779,11 @@ class DateTimePickerSeleniumTests(AdminWidgetSeleniumTestCase):
# Press the ESC key
self.selenium.find_element_by_tag_name('body').send_keys([Keys.ESCAPE])
# The time picker is hidden again
self.assertEqual(self.get_css_value('#clockbox0', 'display'), 'none')
self.assertFalse(self.selenium.find_element_by_id('clockbox0').is_displayed())
# Click the time icon, then select the 'Noon' value
time_icon.click()
self.selenium.find_element_by_xpath("//a[contains(text(), 'Noon')]").click()
self.assertEqual(self.get_css_value('#clockbox0', 'display'), 'none')
self.assertFalse(self.selenium.find_element_by_id('clockbox0').is_displayed())
self.assertEqual(
self.selenium.find_element_by_id('id_birthdate_1').get_attribute('value'),
'12:00:00',