summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulien Phalip <jphalip@gmail.com>2012-03-05 08:13:09 +0000
committerJulien Phalip <jphalip@gmail.com>2012-03-05 08:13:09 +0000
commit399aa72330d806d2cde36f3e8d0acce11b5f2f4a (patch)
treee859cfe79430b2c44a62e8851625bee584848b0b
parent8c9b032ea03911185622ea4ef12ccea5ee7e3455 (diff)
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
-rw-r--r--django/contrib/admin/tests.py4
-rw-r--r--tests/regressiontests/admin_inlines/tests.py47
-rwxr-xr-xtests/regressiontests/admin_views/tests.py18
-rw-r--r--tests/regressiontests/admin_widgets/tests.py12
4 files changed, 56 insertions, 25 deletions
diff --git a/django/contrib/admin/tests.py b/django/contrib/admin/tests.py
index 9ad817d4a7..2491fc65b1 100644
--- a/django/contrib/admin/tests.py
+++ b/django/contrib/admin/tests.py
@@ -79,7 +79,7 @@ class AdminSeleniumWebDriverTestCase(LiveServerTestCase):
identified by the CSS selector `selector`.
"""
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:
if option.get_attribute('value') == value:
return option
@@ -90,7 +90,7 @@ class AdminSeleniumWebDriverTestCase(LiveServerTestCase):
Asserts that the <SELECT> widget identified by `selector` has the
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 = []
for option in options:
actual_values.append(option.get_attribute('value'))
diff --git a/tests/regressiontests/admin_inlines/tests.py b/tests/regressiontests/admin_inlines/tests.py
index bb8418be21..8b620cc57d 100644
--- a/tests/regressiontests/admin_inlines/tests.py
+++ b/tests/regressiontests/admin_inlines/tests.py
@@ -394,6 +394,7 @@ class SeleniumFirefoxTests(AdminSeleniumWebDriverTestCase):
Ensure that the "Add another XXX" link correctly adds items to the
inline form.
"""
+ from selenium.common.exceptions import TimeoutException
self.admin_login(username='super', password='secret')
self.selenium.get('%s%s' % (self.live_server_url,
'/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
# correct ID.
self.failUnlessEqual(len(self.selenium.find_elements_by_css_selector(
- '#profile_set-group table tr.dynamic-profile_set')), 1)
- self.failUnlessEqual(self.selenium.find_element_by_css_selector(
- '.dynamic-profile_set:nth-of-type(1)').get_attribute('id'),
+ '.dynamic-profile_set')), 1)
+ self.failUnlessEqual(self.selenium.find_elements_by_css_selector(
+ '.dynamic-profile_set')[0].get_attribute('id'),
'profile_set-0')
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(
- '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
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
# that it contains the right fields.
self.failUnlessEqual(len(self.selenium.find_elements_by_css_selector(
- '#profile_set-group table tr.dynamic-profile_set')), 2)
- self.failUnlessEqual(self.selenium.find_element_by_css_selector(
- '.dynamic-profile_set:nth-of-type(2)').get_attribute('id'), 'profile_set-1')
+ '.dynamic-profile_set')), 2)
+ self.failUnlessEqual(self.selenium.find_elements_by_css_selector(
+ '.dynamic-profile_set')[1].get_attribute('id'), 'profile_set-1')
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(
- '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
self.selenium.find_element_by_link_text('Add another Profile').click()
self.failUnlessEqual(len(self.selenium.find_elements_by_css_selector(
- '#profile_set-group table tr.dynamic-profile_set')), 3)
- self.failUnlessEqual(self.selenium.find_element_by_css_selector(
- '.dynamic-profile_set:nth-of-type(3)').get_attribute('id'), 'profile_set-2')
+ '.dynamic-profile_set')), 3)
+ self.failUnlessEqual(self.selenium.find_elements_by_css_selector(
+ '.dynamic-profile_set')[2].get_attribute('id'), 'profile_set-2')
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(
- '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'
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-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_xpath('//input[@value="Save"]').click()
- # Wait for the next page to be loaded.
- self.wait_loaded_tag('body')
+ 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
# Check that the objects have been created in the database
self.assertEqual(ProfileCollection.objects.all().count(), 1)
@@ -491,4 +499,7 @@ class SeleniumFirefoxTests(AdminSeleniumWebDriverTestCase):
class SeleniumChromeTests(SeleniumFirefoxTests):
- webdriver_class = 'selenium.webdriver.chrome.webdriver.WebDriver' \ No newline at end of file
+ webdriver_class = 'selenium.webdriver.chrome.webdriver.WebDriver'
+
+class SeleniumIETests(SeleniumFirefoxTests):
+ webdriver_class = 'selenium.webdriver.ie.webdriver.WebDriver' \ No newline at end of file
diff --git a/tests/regressiontests/admin_views/tests.py b/tests/regressiontests/admin_views/tests.py
index 5241d263a7..12f1c677af 100755
--- a/tests/regressiontests/admin_views/tests.py
+++ b/tests/regressiontests/admin_views/tests.py
@@ -2934,6 +2934,7 @@ class SeleniumPrePopulatedFirefoxTests(AdminSeleniumWebDriverTestCase):
main form and with stacked and tabular inlines.
Refs #13068, #9264, #9983, #9784.
"""
+ from selenium.common.exceptions import TimeoutException
self.admin_login(username='super', password='secret', login_url='/test_admin/admin/')
self.selenium.get('%s%s' % (self.live_server_url,
'/test_admin/admin/admin_views/mainprepopulated/add/'))
@@ -2958,7 +2959,7 @@ class SeleniumPrePopulatedFirefoxTests(AdminSeleniumWebDriverTestCase):
self.assertEqual(slug2, 'option-one-here-stacked-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.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... ')
@@ -2978,7 +2979,7 @@ class SeleniumPrePopulatedFirefoxTests(AdminSeleniumWebDriverTestCase):
self.assertEqual(slug2, 'option-two-and-now-tabular-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.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')
@@ -2989,6 +2990,16 @@ class SeleniumPrePopulatedFirefoxTests(AdminSeleniumWebDriverTestCase):
# Save and check that everything is properly stored in the database
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)
MainPrepopulated.objects.get(
name=u' this is the mAin nÀMë and it\'s awεšome',
@@ -3031,6 +3042,9 @@ class SeleniumPrePopulatedFirefoxTests(AdminSeleniumWebDriverTestCase):
class SeleniumPrePopulatedChromeTests(SeleniumPrePopulatedFirefoxTests):
webdriver_class = 'selenium.webdriver.chrome.webdriver.WebDriver'
+class SeleniumPrePopulatedIETests(SeleniumPrePopulatedFirefoxTests):
+ webdriver_class = 'selenium.webdriver.ie.webdriver.WebDriver'
+
class ReadonlyTest(TestCase):
urls = "regressiontests.admin_views.urls"
diff --git a/tests/regressiontests/admin_widgets/tests.py b/tests/regressiontests/admin_widgets/tests.py
index 94ee5a9fe9..87e0309ddc 100644
--- a/tests/regressiontests/admin_widgets/tests.py
+++ b/tests/regressiontests/admin_widgets/tests.py
@@ -462,6 +462,9 @@ class DateTimePickerSeleniumFirefoxTests(AdminSeleniumWebDriverTestCase):
class DateTimePickerSeleniumChromeTests(DateTimePickerSeleniumFirefoxTests):
webdriver_class = 'selenium.webdriver.chrome.webdriver.WebDriver'
+class DateTimePickerSeleniumIETests(DateTimePickerSeleniumFirefoxTests):
+ webdriver_class = 'selenium.webdriver.ie.webdriver.WebDriver'
+
class HorizontalVerticalFilterSeleniumFirefoxTests(AdminSeleniumWebDriverTestCase):
webdriver_class = 'selenium.webdriver.firefox.webdriver.WebDriver'
@@ -515,7 +518,7 @@ class HorizontalVerticalFilterSeleniumFirefoxTests(AdminSeleniumWebDriverTestCas
elif mode == 'vertical':
# There 's no 'Choose all' button in vertical mode, so individually
# 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()
self.selenium.find_element_by_id(choose_link).click()
self.assertSelectOptions(from_box, [])
@@ -532,7 +535,7 @@ class HorizontalVerticalFilterSeleniumFirefoxTests(AdminSeleniumWebDriverTestCas
elif mode == 'vertical':
# There 's no 'Remove all' button in vertical mode, so individually
# 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()
self.selenium.find_element_by_id(remove_link).click()
self.assertSelectOptions(from_box,
@@ -685,4 +688,7 @@ class HorizontalVerticalFilterSeleniumFirefoxTests(AdminSeleniumWebDriverTestCas
[self.jason, self.peter])
class HorizontalVerticalFilterSeleniumChromeTests(HorizontalVerticalFilterSeleniumFirefoxTests):
- webdriver_class = 'selenium.webdriver.chrome.webdriver.WebDriver' \ No newline at end of file
+ webdriver_class = 'selenium.webdriver.chrome.webdriver.WebDriver'
+
+class HorizontalVerticalFilterSeleniumIETests(HorizontalVerticalFilterSeleniumFirefoxTests):
+ webdriver_class = 'selenium.webdriver.ie.webdriver.WebDriver' \ No newline at end of file