summaryrefslogtreecommitdiff
path: root/django
diff options
context:
space:
mode:
authorAnssi Kääriäinen <akaariai@gmail.com>2013-02-20 03:08:55 +0200
committerAnssi Kääriäinen <akaariai@gmail.com>2013-02-21 00:03:39 +0200
commit3872bc51c966ac779f24772e24511423491ea49e (patch)
tree4766677a06f160d1f13ace9d1536bfd46679d9bc /django
parent67a937c2c24b7eee8be13a1d3faff595d8f45839 (diff)
[1.4.x] Made a couple of selenium tests wait for page loaded
The admin_widgets tests were issuing click() to the browser but didn't wait for the effects of those clicks. This caused the resulting request to be processed concurrently with the test case. When using in-memory SQLite this caused weird failures. Also added wait_page_loaded() to admin selenium tests for code reuse. Fixed #19856, cherry-pick of 50677b29af39ca670274fb45087415c883c78b04
Diffstat (limited to 'django')
-rw-r--r--django/contrib/admin/tests.py17
1 files changed, 15 insertions, 2 deletions
diff --git a/django/contrib/admin/tests.py b/django/contrib/admin/tests.py
index 9d94127b34..a66e89f06d 100644
--- a/django/contrib/admin/tests.py
+++ b/django/contrib/admin/tests.py
@@ -49,6 +49,20 @@ class AdminSeleniumWebDriverTestCase(LiveServerTestCase):
timeout
)
+ def wait_page_loaded(self):
+ """
+ Block until page has started to load.
+ """
+ from selenium.common.exceptions import TimeoutException
+ 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
+
def admin_login(self, username, password, login_url='/admin/'):
"""
Helper function to log into the admin.
@@ -61,8 +75,7 @@ class AdminSeleniumWebDriverTestCase(LiveServerTestCase):
login_text = _('Log in')
self.selenium.find_element_by_xpath(
'//input[@value="%s"]' % login_text).click()
- # Wait for the next page to be loaded.
- self.wait_loaded_tag('body')
+ self.wait_page_loaded()
def get_css_value(self, selector, attribute):
"""