-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathselenium_test_case.py
67 lines (52 loc) · 1.92 KB
/
selenium_test_case.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
from djangosanetesting.cases import SeleniumTestCase
from django.core.management import call_command
from django.core.cache import cache
import time
try:
from celery.task.control import discard_all
except:
pass
class DjangoFunctionalSeleniumTestCase(SeleniumTestCase):
# selenium_fixtures = []
def setUp(self, *args, **kwargs):
self.verificationErrors = []
def tearDown(self, *args, **kwargs):
if hasattr(self,"verificationErrors"):
self.assertEqual([], self.verificationErrors)
def js_refresh(self):
sel = self.selenium
sel.get_eval("this.browserbot.getUserWindow().location.href")
sel.get_eval("this.browserbot.getUserWindow().location.href=window.location.href;")
time.sleep(4)
def click_and_wait(self, link):
sel = self.selenium
sel.click(link)
sel.wait_for_page_to_load("30000")
def close(self):
sel = self.selenium
sel.get_eval("this.browserbot.getUserWindow().close()")
try:
sel.get_confirmation()
except:
pass
class DjangoFunctionalConservativeSeleniumTestCase(DjangoFunctionalSeleniumTestCase):
def tearDown(self, *args, **kwargs):
try:
discard_all()
except:
pass
super(DjangoFunctionalConservativeSeleniumTestCase,self).tearDown(*args, **kwargs)
call_command('flush', interactive=False)
cache.clear()
class DjangoFunctionalUnitTestMixin(object):
def assertEqualQuerySets(self, q1, q2):
self.assertEqual(list(q1),list(q2))
class DjangoFunctionalConservativeUnitTestMixin(DjangoFunctionalUnitTestMixin):
def tearDown(self, *args, **kwargs):
try:
discard_all()
except:
pass
super(DjangoFunctionalConservativeUnitTestMixin,self).tearDown(*args, **kwargs)
call_command('flush', interactive=False)
cache.clear()