Enabled the existing admin Selenium tests to be run with Internet Explorer. Note that some tweaks had to be made, in particular as IE7 has limited capabilities regarding CSS selectors.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@17666 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
8c9b032ea0
commit
399aa72330
|
@ -79,7 +79,7 @@ class AdminSeleniumWebDriverTestCase(LiveServerTestCase):
|
||||||
identified by the CSS selector `selector`.
|
identified by the CSS selector `selector`.
|
||||||
"""
|
"""
|
||||||
from selenium.common.exceptions import NoSuchElementException
|
from selenium.common.exceptions import NoSuchElementException
|
||||||
options = self.selenium.find_elements_by_css_selector('%s option' % selector)
|
options = self.selenium.find_elements_by_css_selector('%s > option' % selector)
|
||||||
for option in options:
|
for option in options:
|
||||||
if option.get_attribute('value') == value:
|
if option.get_attribute('value') == value:
|
||||||
return option
|
return option
|
||||||
|
@ -90,7 +90,7 @@ class AdminSeleniumWebDriverTestCase(LiveServerTestCase):
|
||||||
Asserts that the <SELECT> widget identified by `selector` has the
|
Asserts that the <SELECT> widget identified by `selector` has the
|
||||||
options with the given `values`.
|
options with the given `values`.
|
||||||
"""
|
"""
|
||||||
options = self.selenium.find_elements_by_css_selector('%s option' % selector)
|
options = self.selenium.find_elements_by_css_selector('%s > option' % selector)
|
||||||
actual_values = []
|
actual_values = []
|
||||||
for option in options:
|
for option in options:
|
||||||
actual_values.append(option.get_attribute('value'))
|
actual_values.append(option.get_attribute('value'))
|
||||||
|
|
|
@ -394,6 +394,7 @@ class SeleniumFirefoxTests(AdminSeleniumWebDriverTestCase):
|
||||||
Ensure that the "Add another XXX" link correctly adds items to the
|
Ensure that the "Add another XXX" link correctly adds items to the
|
||||||
inline form.
|
inline form.
|
||||||
"""
|
"""
|
||||||
|
from selenium.common.exceptions import TimeoutException
|
||||||
self.admin_login(username='super', password='secret')
|
self.admin_login(username='super', password='secret')
|
||||||
self.selenium.get('%s%s' % (self.live_server_url,
|
self.selenium.get('%s%s' % (self.live_server_url,
|
||||||
'/admin/admin_inlines/profilecollection/add/'))
|
'/admin/admin_inlines/profilecollection/add/'))
|
||||||
|
@ -401,14 +402,14 @@ class SeleniumFirefoxTests(AdminSeleniumWebDriverTestCase):
|
||||||
# Check that there's only one inline to start with and that it has the
|
# Check that there's only one inline to start with and that it has the
|
||||||
# correct ID.
|
# correct ID.
|
||||||
self.failUnlessEqual(len(self.selenium.find_elements_by_css_selector(
|
self.failUnlessEqual(len(self.selenium.find_elements_by_css_selector(
|
||||||
'#profile_set-group table tr.dynamic-profile_set')), 1)
|
'.dynamic-profile_set')), 1)
|
||||||
self.failUnlessEqual(self.selenium.find_element_by_css_selector(
|
self.failUnlessEqual(self.selenium.find_elements_by_css_selector(
|
||||||
'.dynamic-profile_set:nth-of-type(1)').get_attribute('id'),
|
'.dynamic-profile_set')[0].get_attribute('id'),
|
||||||
'profile_set-0')
|
'profile_set-0')
|
||||||
self.failUnlessEqual(len(self.selenium.find_elements_by_css_selector(
|
self.failUnlessEqual(len(self.selenium.find_elements_by_css_selector(
|
||||||
'form#profilecollection_form tr.dynamic-profile_set#profile_set-0 input[name=profile_set-0-first_name]')), 1)
|
'.dynamic-profile_set#profile_set-0 input[name=profile_set-0-first_name]')), 1)
|
||||||
self.failUnlessEqual(len(self.selenium.find_elements_by_css_selector(
|
self.failUnlessEqual(len(self.selenium.find_elements_by_css_selector(
|
||||||
'form#profilecollection_form tr.dynamic-profile_set#profile_set-0 input[name=profile_set-0-last_name]')), 1)
|
'.dynamic-profile_set#profile_set-0 input[name=profile_set-0-last_name]')), 1)
|
||||||
|
|
||||||
# Add an inline
|
# Add an inline
|
||||||
self.selenium.find_element_by_link_text('Add another Profile').click()
|
self.selenium.find_element_by_link_text('Add another Profile').click()
|
||||||
|
@ -416,24 +417,24 @@ class SeleniumFirefoxTests(AdminSeleniumWebDriverTestCase):
|
||||||
# Check that the inline has been added, that it has the right id, and
|
# Check that the inline has been added, that it has the right id, and
|
||||||
# that it contains the right fields.
|
# that it contains the right fields.
|
||||||
self.failUnlessEqual(len(self.selenium.find_elements_by_css_selector(
|
self.failUnlessEqual(len(self.selenium.find_elements_by_css_selector(
|
||||||
'#profile_set-group table tr.dynamic-profile_set')), 2)
|
'.dynamic-profile_set')), 2)
|
||||||
self.failUnlessEqual(self.selenium.find_element_by_css_selector(
|
self.failUnlessEqual(self.selenium.find_elements_by_css_selector(
|
||||||
'.dynamic-profile_set:nth-of-type(2)').get_attribute('id'), 'profile_set-1')
|
'.dynamic-profile_set')[1].get_attribute('id'), 'profile_set-1')
|
||||||
self.failUnlessEqual(len(self.selenium.find_elements_by_css_selector(
|
self.failUnlessEqual(len(self.selenium.find_elements_by_css_selector(
|
||||||
'form#profilecollection_form tr.dynamic-profile_set#profile_set-1 input[name=profile_set-1-first_name]')), 1)
|
'.dynamic-profile_set#profile_set-1 input[name=profile_set-1-first_name]')), 1)
|
||||||
self.failUnlessEqual(len(self.selenium.find_elements_by_css_selector(
|
self.failUnlessEqual(len(self.selenium.find_elements_by_css_selector(
|
||||||
'form#profilecollection_form tr.dynamic-profile_set#profile_set-1 input[name=profile_set-1-last_name]')), 1)
|
'.dynamic-profile_set#profile_set-1 input[name=profile_set-1-last_name]')), 1)
|
||||||
|
|
||||||
# Let's add another one to be sure
|
# Let's add another one to be sure
|
||||||
self.selenium.find_element_by_link_text('Add another Profile').click()
|
self.selenium.find_element_by_link_text('Add another Profile').click()
|
||||||
self.failUnlessEqual(len(self.selenium.find_elements_by_css_selector(
|
self.failUnlessEqual(len(self.selenium.find_elements_by_css_selector(
|
||||||
'#profile_set-group table tr.dynamic-profile_set')), 3)
|
'.dynamic-profile_set')), 3)
|
||||||
self.failUnlessEqual(self.selenium.find_element_by_css_selector(
|
self.failUnlessEqual(self.selenium.find_elements_by_css_selector(
|
||||||
'.dynamic-profile_set:nth-of-type(3)').get_attribute('id'), 'profile_set-2')
|
'.dynamic-profile_set')[2].get_attribute('id'), 'profile_set-2')
|
||||||
self.failUnlessEqual(len(self.selenium.find_elements_by_css_selector(
|
self.failUnlessEqual(len(self.selenium.find_elements_by_css_selector(
|
||||||
'form#profilecollection_form tr.dynamic-profile_set#profile_set-2 input[name=profile_set-2-first_name]')), 1)
|
'.dynamic-profile_set#profile_set-2 input[name=profile_set-2-first_name]')), 1)
|
||||||
self.failUnlessEqual(len(self.selenium.find_elements_by_css_selector(
|
self.failUnlessEqual(len(self.selenium.find_elements_by_css_selector(
|
||||||
'form#profilecollection_form tr.dynamic-profile_set#profile_set-2 input[name=profile_set-2-last_name]')), 1)
|
'.dynamic-profile_set#profile_set-2 input[name=profile_set-2-last_name]')), 1)
|
||||||
|
|
||||||
# Enter some data and click 'Save'
|
# Enter some data and click 'Save'
|
||||||
self.selenium.find_element_by_name('profile_set-0-first_name').send_keys('0 first name 1')
|
self.selenium.find_element_by_name('profile_set-0-first_name').send_keys('0 first name 1')
|
||||||
|
@ -442,10 +443,17 @@ class SeleniumFirefoxTests(AdminSeleniumWebDriverTestCase):
|
||||||
self.selenium.find_element_by_name('profile_set-1-last_name').send_keys('1 last name 2')
|
self.selenium.find_element_by_name('profile_set-1-last_name').send_keys('1 last name 2')
|
||||||
self.selenium.find_element_by_name('profile_set-2-first_name').send_keys('2 first name 1')
|
self.selenium.find_element_by_name('profile_set-2-first_name').send_keys('2 first name 1')
|
||||||
self.selenium.find_element_by_name('profile_set-2-last_name').send_keys('2 last name 2')
|
self.selenium.find_element_by_name('profile_set-2-last_name').send_keys('2 last name 2')
|
||||||
|
|
||||||
self.selenium.find_element_by_xpath('//input[@value="Save"]').click()
|
self.selenium.find_element_by_xpath('//input[@value="Save"]').click()
|
||||||
|
|
||||||
# Wait for the next page to be loaded.
|
try:
|
||||||
self.wait_loaded_tag('body')
|
# Wait for the next page to be loaded.
|
||||||
|
self.wait_loaded_tag('body')
|
||||||
|
except TimeoutException:
|
||||||
|
# IE7 occasionnally returns an error "Internet Explorer cannot
|
||||||
|
# display the webpage" and doesn't load the next page. We just
|
||||||
|
# ignore it.
|
||||||
|
pass
|
||||||
|
|
||||||
# Check that the objects have been created in the database
|
# Check that the objects have been created in the database
|
||||||
self.assertEqual(ProfileCollection.objects.all().count(), 1)
|
self.assertEqual(ProfileCollection.objects.all().count(), 1)
|
||||||
|
@ -491,4 +499,7 @@ class SeleniumFirefoxTests(AdminSeleniumWebDriverTestCase):
|
||||||
|
|
||||||
|
|
||||||
class SeleniumChromeTests(SeleniumFirefoxTests):
|
class SeleniumChromeTests(SeleniumFirefoxTests):
|
||||||
webdriver_class = 'selenium.webdriver.chrome.webdriver.WebDriver'
|
webdriver_class = 'selenium.webdriver.chrome.webdriver.WebDriver'
|
||||||
|
|
||||||
|
class SeleniumIETests(SeleniumFirefoxTests):
|
||||||
|
webdriver_class = 'selenium.webdriver.ie.webdriver.WebDriver'
|
|
@ -2934,6 +2934,7 @@ class SeleniumPrePopulatedFirefoxTests(AdminSeleniumWebDriverTestCase):
|
||||||
main form and with stacked and tabular inlines.
|
main form and with stacked and tabular inlines.
|
||||||
Refs #13068, #9264, #9983, #9784.
|
Refs #13068, #9264, #9983, #9784.
|
||||||
"""
|
"""
|
||||||
|
from selenium.common.exceptions import TimeoutException
|
||||||
self.admin_login(username='super', password='secret', login_url='/test_admin/admin/')
|
self.admin_login(username='super', password='secret', login_url='/test_admin/admin/')
|
||||||
self.selenium.get('%s%s' % (self.live_server_url,
|
self.selenium.get('%s%s' % (self.live_server_url,
|
||||||
'/test_admin/admin/admin_views/mainprepopulated/add/'))
|
'/test_admin/admin/admin_views/mainprepopulated/add/'))
|
||||||
|
@ -2958,7 +2959,7 @@ class SeleniumPrePopulatedFirefoxTests(AdminSeleniumWebDriverTestCase):
|
||||||
self.assertEqual(slug2, 'option-one-here-stacked-inline')
|
self.assertEqual(slug2, 'option-one-here-stacked-inline')
|
||||||
|
|
||||||
# Add an inline
|
# Add an inline
|
||||||
self.selenium.find_element_by_css_selector('#relatedprepopulated_set-group .add-row a').click()
|
self.selenium.find_elements_by_link_text('Add another Related Prepopulated')[0].click()
|
||||||
self.selenium.find_element_by_css_selector('#id_relatedprepopulated_set-1-pubdate').send_keys('1999-01-25')
|
self.selenium.find_element_by_css_selector('#id_relatedprepopulated_set-1-pubdate').send_keys('1999-01-25')
|
||||||
self.get_select_option('#id_relatedprepopulated_set-1-status', 'option two').click()
|
self.get_select_option('#id_relatedprepopulated_set-1-status', 'option two').click()
|
||||||
self.selenium.find_element_by_css_selector('#id_relatedprepopulated_set-1-name').send_keys(u' now you haVe anöther sŤāÇkeð inline with a very ... loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooog text... ')
|
self.selenium.find_element_by_css_selector('#id_relatedprepopulated_set-1-name').send_keys(u' now you haVe anöther sŤāÇkeð inline with a very ... loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooog text... ')
|
||||||
|
@ -2978,7 +2979,7 @@ class SeleniumPrePopulatedFirefoxTests(AdminSeleniumWebDriverTestCase):
|
||||||
self.assertEqual(slug2, 'option-two-and-now-tabular-inline')
|
self.assertEqual(slug2, 'option-two-and-now-tabular-inline')
|
||||||
|
|
||||||
# Add an inline
|
# Add an inline
|
||||||
self.selenium.find_element_by_css_selector('#relatedprepopulated_set-2-group .add-row a').click()
|
self.selenium.find_elements_by_link_text('Add another Related Prepopulated')[1].click()
|
||||||
self.selenium.find_element_by_css_selector('#id_relatedprepopulated_set-2-1-pubdate').send_keys('1981-08-22')
|
self.selenium.find_element_by_css_selector('#id_relatedprepopulated_set-2-1-pubdate').send_keys('1981-08-22')
|
||||||
self.get_select_option('#id_relatedprepopulated_set-2-1-status', 'option one').click()
|
self.get_select_option('#id_relatedprepopulated_set-2-1-status', 'option one').click()
|
||||||
self.selenium.find_element_by_css_selector('#id_relatedprepopulated_set-2-1-name').send_keys(u'a tÃbűlaŘ inline with ignored ;"&*^\%$#@-/`~ characters')
|
self.selenium.find_element_by_css_selector('#id_relatedprepopulated_set-2-1-name').send_keys(u'a tÃbűlaŘ inline with ignored ;"&*^\%$#@-/`~ characters')
|
||||||
|
@ -2989,6 +2990,16 @@ class SeleniumPrePopulatedFirefoxTests(AdminSeleniumWebDriverTestCase):
|
||||||
|
|
||||||
# Save and check that everything is properly stored in the database
|
# Save and check that everything is properly stored in the database
|
||||||
self.selenium.find_element_by_xpath('//input[@value="Save"]').click()
|
self.selenium.find_element_by_xpath('//input[@value="Save"]').click()
|
||||||
|
|
||||||
|
try:
|
||||||
|
# Wait for the next page to be loaded.
|
||||||
|
self.wait_loaded_tag('body')
|
||||||
|
except TimeoutException:
|
||||||
|
# IE7 occasionnally returns an error "Internet Explorer cannot
|
||||||
|
# display the webpage" and doesn't load the next page. We just
|
||||||
|
# ignore it.
|
||||||
|
pass
|
||||||
|
|
||||||
self.assertEqual(MainPrepopulated.objects.all().count(), 1)
|
self.assertEqual(MainPrepopulated.objects.all().count(), 1)
|
||||||
MainPrepopulated.objects.get(
|
MainPrepopulated.objects.get(
|
||||||
name=u' this is the mAin nÀMë and it\'s awεšome',
|
name=u' this is the mAin nÀMë and it\'s awεšome',
|
||||||
|
@ -3031,6 +3042,9 @@ class SeleniumPrePopulatedFirefoxTests(AdminSeleniumWebDriverTestCase):
|
||||||
class SeleniumPrePopulatedChromeTests(SeleniumPrePopulatedFirefoxTests):
|
class SeleniumPrePopulatedChromeTests(SeleniumPrePopulatedFirefoxTests):
|
||||||
webdriver_class = 'selenium.webdriver.chrome.webdriver.WebDriver'
|
webdriver_class = 'selenium.webdriver.chrome.webdriver.WebDriver'
|
||||||
|
|
||||||
|
class SeleniumPrePopulatedIETests(SeleniumPrePopulatedFirefoxTests):
|
||||||
|
webdriver_class = 'selenium.webdriver.ie.webdriver.WebDriver'
|
||||||
|
|
||||||
|
|
||||||
class ReadonlyTest(TestCase):
|
class ReadonlyTest(TestCase):
|
||||||
urls = "regressiontests.admin_views.urls"
|
urls = "regressiontests.admin_views.urls"
|
||||||
|
|
|
@ -462,6 +462,9 @@ class DateTimePickerSeleniumFirefoxTests(AdminSeleniumWebDriverTestCase):
|
||||||
class DateTimePickerSeleniumChromeTests(DateTimePickerSeleniumFirefoxTests):
|
class DateTimePickerSeleniumChromeTests(DateTimePickerSeleniumFirefoxTests):
|
||||||
webdriver_class = 'selenium.webdriver.chrome.webdriver.WebDriver'
|
webdriver_class = 'selenium.webdriver.chrome.webdriver.WebDriver'
|
||||||
|
|
||||||
|
class DateTimePickerSeleniumIETests(DateTimePickerSeleniumFirefoxTests):
|
||||||
|
webdriver_class = 'selenium.webdriver.ie.webdriver.WebDriver'
|
||||||
|
|
||||||
|
|
||||||
class HorizontalVerticalFilterSeleniumFirefoxTests(AdminSeleniumWebDriverTestCase):
|
class HorizontalVerticalFilterSeleniumFirefoxTests(AdminSeleniumWebDriverTestCase):
|
||||||
webdriver_class = 'selenium.webdriver.firefox.webdriver.WebDriver'
|
webdriver_class = 'selenium.webdriver.firefox.webdriver.WebDriver'
|
||||||
|
@ -515,7 +518,7 @@ class HorizontalVerticalFilterSeleniumFirefoxTests(AdminSeleniumWebDriverTestCas
|
||||||
elif mode == 'vertical':
|
elif mode == 'vertical':
|
||||||
# There 's no 'Choose all' button in vertical mode, so individually
|
# There 's no 'Choose all' button in vertical mode, so individually
|
||||||
# select all options and click 'Choose'.
|
# select all options and click 'Choose'.
|
||||||
for option in self.selenium.find_elements_by_css_selector(from_box + ' option'):
|
for option in self.selenium.find_elements_by_css_selector(from_box + ' > option'):
|
||||||
option.click()
|
option.click()
|
||||||
self.selenium.find_element_by_id(choose_link).click()
|
self.selenium.find_element_by_id(choose_link).click()
|
||||||
self.assertSelectOptions(from_box, [])
|
self.assertSelectOptions(from_box, [])
|
||||||
|
@ -532,7 +535,7 @@ class HorizontalVerticalFilterSeleniumFirefoxTests(AdminSeleniumWebDriverTestCas
|
||||||
elif mode == 'vertical':
|
elif mode == 'vertical':
|
||||||
# There 's no 'Remove all' button in vertical mode, so individually
|
# There 's no 'Remove all' button in vertical mode, so individually
|
||||||
# select all options and click 'Remove'.
|
# select all options and click 'Remove'.
|
||||||
for option in self.selenium.find_elements_by_css_selector(to_box + ' option'):
|
for option in self.selenium.find_elements_by_css_selector(to_box + ' > option'):
|
||||||
option.click()
|
option.click()
|
||||||
self.selenium.find_element_by_id(remove_link).click()
|
self.selenium.find_element_by_id(remove_link).click()
|
||||||
self.assertSelectOptions(from_box,
|
self.assertSelectOptions(from_box,
|
||||||
|
@ -685,4 +688,7 @@ class HorizontalVerticalFilterSeleniumFirefoxTests(AdminSeleniumWebDriverTestCas
|
||||||
[self.jason, self.peter])
|
[self.jason, self.peter])
|
||||||
|
|
||||||
class HorizontalVerticalFilterSeleniumChromeTests(HorizontalVerticalFilterSeleniumFirefoxTests):
|
class HorizontalVerticalFilterSeleniumChromeTests(HorizontalVerticalFilterSeleniumFirefoxTests):
|
||||||
webdriver_class = 'selenium.webdriver.chrome.webdriver.WebDriver'
|
webdriver_class = 'selenium.webdriver.chrome.webdriver.WebDriver'
|
||||||
|
|
||||||
|
class HorizontalVerticalFilterSeleniumIETests(HorizontalVerticalFilterSeleniumFirefoxTests):
|
||||||
|
webdriver_class = 'selenium.webdriver.ie.webdriver.WebDriver'
|
Loading…
Reference in New Issue