~ubuntu-branches/ubuntu/saucy/python-django/saucy-updates

« back to all changes in this revision

Viewing changes to django/contrib/admin/tests.py

  • Committer: Package Import Robot
  • Author(s): Luke Faraone, Jakub Wilk, Luke Faraone
  • Date: 2013-05-09 15:10:47 UTC
  • mfrom: (1.1.21) (4.4.27 sid)
  • Revision ID: package-import@ubuntu.com-20130509151047-aqv8d71oj9wvcv8c
Tags: 1.5.1-2
[ Jakub Wilk ]
* Use canonical URIs for Vcs-* fields.

[ Luke Faraone ]
* Upload to unstable.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
import sys
2
 
 
3
1
from django.test import LiveServerTestCase
4
2
from django.utils.importlib import import_module
5
3
from django.utils.unittest import SkipTest
10
8
 
11
9
    @classmethod
12
10
    def setUpClass(cls):
13
 
        if sys.version_info < (2, 6):
14
 
            raise SkipTest('Selenium Webdriver does not support Python < 2.6.')
15
11
        try:
16
12
            # Import and start the WebDriver class.
17
13
            module, attr = cls.webdriver_class.rsplit('.', 1)
18
14
            mod = import_module(module)
19
15
            WebDriver = getattr(mod, attr)
20
16
            cls.selenium = WebDriver()
21
 
        except Exception, e:
 
17
        except Exception as e:
22
18
            raise SkipTest('Selenium webdriver "%s" not installed or not '
23
19
                           'operational: %s' % (cls.webdriver_class, str(e)))
24
20
        super(AdminSeleniumWebDriverTestCase, cls).setUpClass()
49
45
            timeout
50
46
        )
51
47
 
 
48
    def wait_page_loaded(self):
 
49
        """
 
50
        Block until page has started to load.
 
51
        """
 
52
        from selenium.common.exceptions import TimeoutException
 
53
        try:
 
54
            # Wait for the next page to be loaded
 
55
            self.wait_loaded_tag('body')
 
56
        except TimeoutException:
 
57
            # IE7 occasionnally returns an error "Internet Explorer cannot
 
58
            # display the webpage" and doesn't load the next page. We just
 
59
            # ignore it.
 
60
            pass
 
61
 
52
62
    def admin_login(self, username, password, login_url='/admin/'):
53
63
        """
54
64
        Helper function to log into the admin.
61
71
        login_text = _('Log in')
62
72
        self.selenium.find_element_by_xpath(
63
73
            '//input[@value="%s"]' % login_text).click()
64
 
        # Wait for the next page to be loaded.
65
 
        self.wait_loaded_tag('body')
 
74
        self.wait_page_loaded()
66
75
 
67
76
    def get_css_value(self, selector, attribute):
68
77
        """