diff options
| author | Simon Charette <charettes@users.noreply.github.com> | 2016-05-03 23:19:24 -0400 |
|---|---|---|
| committer | Simon Charette <charettes@users.noreply.github.com> | 2016-05-03 23:19:24 -0400 |
| commit | ad0f536e1c80e7122f03ae4746a90904a573b4b8 (patch) | |
| tree | 69fc3fbb2cfae03c48ef7a5c64e4a5abfc57e91e /django/test/selenium.py | |
| parent | 575a9a791e62de7550761970dc6797271d956c57 (diff) | |
Fixed #26577 -- Disabled implicit wait of Selenium tests where appropriate.
Diffstat (limited to 'django/test/selenium.py')
| -rw-r--r-- | django/test/selenium.py | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/django/test/selenium.py b/django/test/selenium.py index 0f9296f7a9..ae8e603a58 100644 --- a/django/test/selenium.py +++ b/django/test/selenium.py @@ -2,6 +2,7 @@ from __future__ import unicode_literals import sys import unittest +from contextlib import contextmanager from django.test import LiveServerTestCase, tag from django.utils.module_loading import import_string @@ -56,11 +57,12 @@ class SeleniumTestCaseBase(type(LiveServerTestCase)): @tag('selenium') class SeleniumTestCase(with_metaclass(SeleniumTestCaseBase, LiveServerTestCase)): + implicit_wait = 10 @classmethod def setUpClass(cls): cls.selenium = cls.create_webdriver() - cls.selenium.implicitly_wait(10) + cls.selenium.implicitly_wait(cls.implicit_wait) super(SeleniumTestCase, cls).setUpClass() @classmethod @@ -71,3 +73,12 @@ class SeleniumTestCase(with_metaclass(SeleniumTestCaseBase, LiveServerTestCase)) if hasattr(cls, 'selenium'): cls.selenium.quit() super(SeleniumTestCase, cls)._tearDownClassInternal() + + @contextmanager + def disable_implicit_wait(self): + """Context manager that disables the default implicit wait.""" + self.selenium.implicitly_wait(0) + try: + yield + finally: + self.selenium.implicitly_wait(self.implicit_wait) |
