|
3#
楼主 |
发表于 2016-9-22 19:47:56
|
只看该作者
#!/usr/bin/env python
#coding:utf-8
from lib2to3.pgen2 import driver
import unittest
from appium.webdriver.common.mobileby import MobileBy
from selenium import webdriver
from Pages import BasePages
from ddt import ddt,data,unpack
from Pages import basetestcase
@ddt
class LoginPage(unittest.TestCase):
@classmethod
def setUpclass(cls):
cls.driver=webdriver.Firefox()
cls.driver.maximize_window()
cls.driver.get('http://bj.58.com')
cls.driver.implicitly_wait(30)
@data(('','',u'您还没有输入账户名'),('','123321',u''),('ljjtest12','',u'您还没有输入密码'))
@unpack
def test_FailLogin(self,value1,value2,expected):
'''验证:错误登陆返回信息'''
BasePages.Login(self.driver,value1,value2)
self.assertEqual(BasePages.getErrorText(self.driver),expected)
def test_successLogin(self,username='ljjtest12',password='123321',):
'''验证:登陆成功'''
BasePages.Login(self.driver,username,password,)
self.assertTrue(MobileBy.ACCESSIBILITY_ID, '退出')
@classmethod
def tearDownClass(cls):
cls.driver.quit()
# def tearDown(self):
# pass
# # self.driver.quit()
if __name__=='__main__':
unittest.main(verbosity=2)
我这个还是报错driver的问题
Error
Traceback (most recent call last):
File "/Library/Python/2.7/site-packages/ddt.py", line 129, in wrapper
return func(self, *args, **kwargs)
File "/Users/lijingjing/PycharmProjects/testcase3/testcase/Test_login.py", line 29, in test_FailLogin
driver=self.driver
AttributeError: 'LoginPage' object has no attribute 'driver' |
|