I have some tests classes that I would like to do a one time setup for, but selenose is not initializing self.driver until setUp.
This works fine:
import nose
from selenose.cases import SeleniumTestCase
class TestCase(SeleniumTestCase):
def setUp(self):
self.driver.get('http://www.google.com')
# Your test here...
def test(self):
print "hi"
if __name__ == '__main__':
nose.main()
This fails
import nose
from selenose.cases import SeleniumTestCase
class TestCase(SeleniumTestCase):
@classmethod
def setUpClass(cls):
cls.driver.get('http://www.google.com')
# Your test here...
def test(self):
print "hi"
if __name__ == '__main__':
nose.main()
Trace:
E
======================================================================
ERROR: test suite for <class 'test.TestCase'>
----------------------------------------------------------------------
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/nose-1.1.2-py2.7.egg/nose/suite.py", line 208, in run
self.setUp()
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/nose-1.1.2-py2.7.egg/nose/suite.py", line 291, in setUp
self.setupContext(ancestor)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/nose-1.1.2-py2.7.egg/nose/suite.py", line 314, in setupContext
try_run(context, names)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/nose-1.1.2-py2.7.egg/nose/util.py", line 478, in try_run
return func()
File "/Users/marc/git/automation/portal/tests/api/test.py", line 9, in setUpClass
cls.driver.get('http://www.google.com')
AttributeError: type object 'TestCase' has no attribute 'driver'
----------------------------------------------------------------------
Ran 0 tests in 0.001s
FAILED (errors=1)
I have some tests classes that I would like to do a one time setup for, but selenose is not initializing self.driver until setUp.
This works fine:
This fails
Trace: