Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Enabled the existing admin Selenium tests to be run with Internet Exp…

…lorer. 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
  • Loading branch information...
commit 399aa72330d806d2cde36f3e8d0acce11b5f2f4a 1 parent 8c9b032
@jphalip jphalip authored
View
4 django/contrib/admin/tests.py
@@ -79,7 +79,7 @@ def get_select_option(self, selector, value):
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 @@ def assertSelectOptions(self, selector, values):
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'))
View
47 tests/regressiontests/admin_inlines/tests.py
@@ -394,6 +394,7 @@ def test_add_inlines(self):
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 @@ def test_add_inlines(self):
# 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 @@ def test_add_inlines(self):
# 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 @@ def test_add_inlines(self):
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 @@ def test_delete_inlines(self):
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'
View
18 tests/regressiontests/admin_views/tests.py
@@ -2934,6 +2934,7 @@ def test_basic(self):
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 @@ def test_basic(self):
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 @@ def test_basic(self):
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 @@ def test_basic(self):
# 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 @@ def test_basic(self):
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"
View
12 tests/regressiontests/admin_widgets/tests.py
@@ -462,6 +462,9 @@ def test_show_hide_date_time_picker_widgets(self):
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 @@ def execute_basic_operations(self, mode, field_name):
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 @@ def execute_basic_operations(self, mode, field_name):
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 @@ def test_filter(self):
[self.jason, self.peter])
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'
Please sign in to comment.
Something went wrong with that request. Please try again.