def test_02_oa_application(self): '''离职申请单元测试''' self.sub_setUp() self.page = RZLoginPage(self.page) self.page.userlogin() qtapplication = QuitApplyLocators(self.page) qtapplication.enter_quitApply_button() sleep(2) qtapplication.quitApply_Email() sleep(1) qtapplication.quitApply_Reason() qtapplication.quitApply_Describe() sleep(2) qtapplication.quitApply_Outstanding() sleep(2) qtapplication.quitApply_FuturePlanning() sleep(2) qtapplication.quitApply_OtherSuggestions() sleep(2) qtapplication.quitApply_AddOperation() sleep(2) qtapplication.quitApply_Deliver() sleep(2) qtapplication.quitApply_Deliver_content() sleep(2) qtapplication.quitApply_Submit() self.sub_tearDown()
def test_02_oa_application(self): '''调出申请单元测试''' self.sub_setUp() self.page = RZLoginPage(self.page) self.page.userlogin() reapplication = reApplyLocators(self.page) reapplication.enter_reApply_button() sleep(2) reapplication.enter_reApply_button() sleep(2) reapplication.reApply_click_depart() sleep(2) reapplication.reApplydepart() sleep(4) reapplication.reApplyposition() sleep(2) reapplication.reApplyreason() sleep(2) reapplication.reApply_add() sleep(2) reapplication.reApply_Deliver() sleep(2) reapplication.reApply_Deliver_content() sleep(2) reapplication.reApply_Submit() self.sub_tearDown()
def test_02_oa_application(self): '''外出申请单元测试''' self.sub_setUp() self.page = RZLoginPage(self.page) self.page.userlogin() oaapplication = OutApplyLocators(self.page) oaapplication.enter_outApply_button() sleep(2) oaapplication.outApply_reason() oaapplication.enter_date_time() ele = oaapplication.success_content self.assertIn('提交成功', ele) self.sub_tearDown()
def test_03_travel_application(self): '''出差申请单元测试''' self.sub_setUp() self.page = RZLoginPage(self.page) self.page.userlogin() travelapplication = TravelAppLocators(self.page) travelapplication.enter_travel_butten() sleep(2) travelapplication.enter_travel_place() travelapplication.enter_travel_reason() travelapplication.enter_date_time() ele = travelapplication.sucess_content self.assertIn('提交成功', ele) self.sub_tearDown()
def test_login(self): datas = ExcelReader(self.excel).data for d in datas: with self.subTest(data=d): self.sub_setUp() self.page.userlogin(d['username'], d['password']) try: self.page = RZLoginPage(self.page) # 页面跳转到result page loginname = self.page.result_name() target_value = d['target_value'] self.assertIn(target_value, loginname) logger.info(loginname) except AssertionError as e: logger.warning(e) self.sub_tearDown()
def test_02_ot_application(self): '''加班申请单元测试''' self.sub_setUp() self.page = RZLoginPage(self.page) self.page.userlogin() otapplication = OtAppLocators(self.page) otapplication.enter_ot_butten() sleep(1) otapplication.enter_ot_place() sleep(1) otapplication.enter_ot_type() sleep(1) otapplication.enter_ot_reason() otapplication.enter_date_time() ele = otapplication.sucess_content self.assertIn('提交成功', ele) self.sub_tearDown()
def sub_setUp(self): # 初始页面是main page,传入浏览器类型打开浏览器 self.page = RZLoginPage().get(self.URL, maximize_window=False, implicitly_wait=20)
def sub_setUp(self): # 初始页面是main page,传入浏览器类型打开浏览器 self.page = RZLoginPage(browser_type='Chrome').get( self.URL, maximize_window=False)
self.find_element(*self.oa_endDate).send_keys(my_date) sleep(3) self.find_element(*self.oa_submit).click() sleep(3) self.content = self.driver.find_element( *self.oa_submit_content).text print(self.content) sleep(5) if self.content == '提交成功': self.success_content = self.content break else: self.find_element(*self.oa_startDate_Form).clear() self.find_element(*self.oa_endDate_Form).clear() x = x + 1 my_date = (datetime.now() + timedelta(days=x)).strftime( "%Y-%m-%d") #timedelta(days)实例支持加减乘除操作 if __name__ == '__main__': URL = Config().get('URL') page = RZLoginPage(browser_type='Chrome').get(URL, maximize_window=False) page.userlogin() result = OutApplyLocators(page) result.enter_outApply_button() sleep(1) result.outApply_reason() sleep(1) result.enter_date_time()
self.find_element(*self.LeaveSubmit).click() sleep(4) self.content = self.driver.find_element( *self.LeaveSubmitContent).get_attribute('innerHTML') print(self.content) sleep(4) if self.content == '提交成功': self.sucess_content = self.content break else: x = x + 1 my_date = (datetime.now() + timedelta(days=x)).strftime( "%Y-%m-%d") #timedelta(days)实例支持加减乘除操作 if __name__ == '__main__': URL = Config().get('URL') page = RZLoginPage(browser_type='Chrome').get(URL, maximize_window=False, implicitly_wait=20) page.userlogin() result = LeaveAppLocators(page) sleep(2) result.enter_leave_butten() sleep(2) result.enter_leave_type() sleep(2) result.enter_leave_reason() sleep(2) result.enter_date_time()