class LoginSuccessCase(unittest.TestCase): def setUp(self) -> None: self.ub = UseBrowser() self.login_page = Loginpage() self.exl = ExlOperation() def test_1_case(self): self.login_page.login(self.exl.get_cell_value(1, 2), self.exl.get_cell_value(1, 3)) self.assertEqual(self.login_page.get_success_text(), self.exl.get_cell_value(1, 4)) def tearDown(self) -> None: UseBrowser.quit()
class Loginpage: def __init__(self): self.op = WebOperation(UseBrowser.driver) self.exl = ExlOperation() self.yam = Yamloperation('../../config/ecation.yaml') self.log = Loginfo() def login(self,username,password): self.log.set_message('info','打开网址') self.op.open_url(self.exl.get_cell_value(1,1)) self.log.set_message('info','输入用户名'+username) self.op.input_text_name(self.yam.get_locator('LoginPage','username'),username) self.log.set_message('info', '输入密码' + password) self.op.input_text_name(self.yam.get_locator('LoginPage','password'),password) self.op.click_xpath(self.yam.get_locator('LoginPage','submit')) # 获取正确信息功能 def get_success_text(self): self.op.change_frame(self.yam.get_locator('LoginPage','framemain')) return self.op.get_text_xpath(self.yam.get_locator('LoginPage','successinfo')) # print(self.op.get_text_xpath('/html/body/table/tbody/tr[1]/td/span')) # 获取登录失败的文本信息 def get_failed_text(self): return self.op.get_text_xpath(self.yam.get_locator('LoginPage','failedinfo')) # if __name__ == '__main__': # ub = UseBrowser() # login = Loginpage() # login.login('admin','admin') # print(login.get_success_text()) # # print(login.get_failed_text()) # ub.quit()
class CustomModifyCase(unittest.TestCase): def setUp(self) -> None: self.ub = UseBrowser() self.customer_page = Customerpage() self.exl = ExlOperation('E:\\test\\logincase.xlsx', 'customer修改用例') self.db = DbCustomoperation() def test_1_customer_name(self): res = self.db.select_customer(self.exl.get_cell_value(1, 2)) self.customer_page.modify_customer(self.exl.get_cell_value(1, 2), self.exl.get_cell_value(1, 3)) self.assertEqual(self.customer_page.get_success_text(), self.exl.get_cell_value(1, 4)) self.db.modify_customer( [res[0]['customerName'], self.exl.get_cell_value(1, 2)]) def tearDown(self) -> None: UseBrowser.quit()
class LoginFailedCase(unittest.TestCase): def setUp(self) -> None: self.ub = UseBrowser() self.login_page = Loginpage() self.exl = ExlOperation() def test_1_name_pwd_null(self): self.login_page.login(self.exl.get_cell_value(2, 2), self.exl.get_cell_value(2, 3)) self.assertEqual(self.login_page.get_failed_text(), self.exl.get_cell_value(2, 4)) def test_2_pwd_error(self): self.login_page.login(self.exl.get_cell_value(3, 2), self.exl.get_cell_value(3, 3)) self.assertEqual(self.login_page.get_failed_text(), self.exl.get_cell_value(3, 4)) def tearDown(self) -> None: UseBrowser.quit()
def setUp(self) -> None: self.ub = UseBrowser() self.customer_page = Customerpage() self.exl = ExlOperation('E:\\test\\logincase.xlsx', 'customer修改用例') self.db = DbCustomoperation()
def setUp(self) -> None: self.ub = UseBrowser() self.login_page = Loginpage() self.exl = ExlOperation()
def __init__(self): self.op = WebOperation(UseBrowser.driver) self.exl = ExlOperation() self.yam = Yamloperation('../../config/ecation.yaml') self.log = Loginfo()