Attributeerror: 'loginpage' Object Has No Attribute 'driver'
Solution 1:
Both your classes extend [Python 2]: class unittest.TestCase(methodName='runTest'). According to [Python 2]: Skipping tests and expected failures
Skipped tests will not have
setUp()ortearDown()run around them. Skipped classes will not havesetUpClass()ortearDownClass()run.
Also, according to [Python 2]: setUpClass and tearDownClass:
If you want the
setUpClassandtearDownClasson base classes called then you must call up to them yourself.
What happens:
- login.py: LoginPage is instantiated (and run) automatically by the unittest framework (
unittest.main()) and setUpClass method is called - which adds the driver attribute to the LoginPage class - and (automatically, to) all its instances Company_Management.py: LoginPage is instantiated manually by you (
em = login.LoginPage()), but the setUpClass method isn't called - and thus LoginPage (or any of its instances) doesn't have the driver attribute - hence your error. To fix it, manually call the method yourself, either:After instantiating the class (on the instance):
em = login.LoginPage() em.setUpClass()On the class itself (better, before instantiating it)
login.LoginPage.setUpClass() em = login.LoginPage()
Post a Comment for "Attributeerror: 'loginpage' Object Has No Attribute 'driver'"