def login(): driver = baseDriver() CP = CalendarPage(driver) LP = LoginPage(driver) MP = MyPage(driver) # self.duix(init) # 1,进入日历界面 CP.accept() # 同意协议 # 2,进入到我的界面 MP.click_My() # 点我的 # 3,点击未登录 MP.click_login_button() # 点击 登录 # 4,输入用户名密码点击登录 LP.click_password_button() # 选择密码验证按钮 yield LP, MP, CP, driver driver.close_app()
class LoginCase(unittest.TestCase): @classmethod def setUpClass(cls): # AppiumServer().start_server() # time.sleep(30) cls.driver = publicDrivers() def setUp(self): self.login_page = LoginPage(self.driver) self.home_page = HomePage(self.driver) def testLogin1(self): """登录,密码错误""" self.home_page.homeMe('testhome') self.login_page.login('testLogin1') self.assertEqual(u'验证码登录',self.login_page.loginAssertFail(),msg=u"断言失败") def testLogin2(self): """登录,账号错误""" self.login_page.login('testLogin2') self.assertEqual(u'验证码登录',self.login_page.loginAssertFail(),msg=u"断言失败") def testLogin3(self): """登录,账号密码正确""" self.login_page.login('testLogin3') self.assertEqual(u'我的',self.login_page.loginAssertPass(),msg=u"断言失败") def tearDown(self): pass @classmethod def tearDownClass(cls): pass
def setUp(self): self.login_page = LoginPage(self.driver) self.home_page = HomePage(self.driver)
def test_phone_err(self): '''用户名或密码错误''' logn = LoginPage(self.driver) data = self.csv_data.get_csv_data(7) logn.loginView(data[0], data[1]) self.assertTrue(logn.check_login_status(), "login fail")
def test_paawd_null(self): '''密码为空''' logn = LoginPage(self.driver) data = self.csv_data.get_csv_data(4) logn.loginView(data[0], data[1]) self.assertTrue(logn.check_login_status(), "login fail")
def test_normal_case(self): '''正常用例''' logn = LoginPage(self.driver) data = self.csv_data.get_csv_data(1) #取配置文件中的第一行 logn.loginView(data[0], data[1]) self.assertTrue(logn.check_login_status())
def setUpClass(cls): super().setUpClass() cls.driver = webdriver.Firefox() cls.login_page = LoginPage(cls.driver)