class OMS(AbTemplate): # sometimes run the file name is file.py sometimes is file.pyc so we need replace by this way # file_name = os.path.basename(__file__).replace(".pyc", "_case").replace(".py", "_case") # case_info = file_name.split("_", 1) # case_id = case_info[0] # case_name = case_info[1] # testcaseinfo = testcaseinfo.TestCaseInfo(case_id, case_name, "功能测试") # logger = noteLog.Loggger(case_name) # testcaseinfo.setLogPath(logger.rel_file) # case info position = "双井 C4" station_value = "双井国贸" # page info stationunit_manage_page = stationunitmanage.StationunitManagePage() stationunit_detail_page = stationunitdetail.StationunitDetailPage() @retrying.retry(retry_on_exception=retry_if_timeout_exception, stop_max_attempt_number=2) def test_case(self): self.util_init(__file__) self.testcaseinfo.starttime = time.strftime("%Y-%m-%d %H:%M:%S") if self.flag > 1: self.setUp() try: self.step = "convert to station manage page" self.logger.info(self.step) self.convert_URL = urldata.URLData().get_station_manage_page_url() self.convert_to_url(self.convert_URL) self.wait_url_to_be(self.convert_URL) self.step = "fill station" self.logger.info(self.step) self.wait_visable(self.stationunit_manage_page.position_box) self.fill(self.stationunit_manage_page.position_box, self.position) self.step = "select station" self.logger.info(self.step) self.Select(self.stationunit_manage_page.station_select, self.station_value) self.step = "click query" self.logger.info(self.step) self.click(self.stationunit_manage_page.query_button) self.step = "click position" self.logger.info(self.step) self.wait_clickable(self.stationunit_manage_page.position_link) self.click(self.stationunit_manage_page.position_link) self.switch_handel() self.step = "click ban button" self.logger.info(self.step) self.wait_clickable(self.stationunit_detail_page.ban_button) self.click(self.stationunit_detail_page.ban_button) self.wait_alert() self.accept_alert() self.step = "validate statu" self.logger.info(self.step) self.wait_a_certain_time(5) flag = self.get_text_Infor(self.stationunit_detail_page.ban_statu) self.assertEquals(flag, "禁用", "状态无法匹配") self.step = "click unban button" self.logger.info(self.step) self.click(self.stationunit_detail_page.ban_button) self.wait_alert() self.accept_alert() self.step = "validate statu" self.logger.info(self.step) flag = self.get_text_Infor(self.stationunit_detail_page.ban_statu) self.assertEquals(flag, "可用", "状态无法匹配") self.testcaseinfo.result = "Pass" pass except TimeoutException: self.timeout_method() except Exception as err: self.exception_method(err) finally: self.finally_method()
class OMS(AbTemplate): # file_name = os.path.basename(__file__).replace(".pyc", "_case").replace(".py", "_case") # case_info = file_name.split("_", 1) # case_id = case_info[0] # case_name = case_info[1] # testcaseinfo = testcaseinfo.TestCaseInfo(case_id, case_name, "功能测试") # logger = noteLog.Loggger(case_name) # testcaseinfo.setLogPath(logger.rel_file) # case info phone_value = "13810345799" # page info user_manage_page = usermanage.UserManagePage() user_detail_page = userdetail.UserDetailPage() order_detail_page = orderdetail.OrderDetail() contract_detail_page = contractdetail.ContactDetailPage() stationunit_detail_page = stationunitdetail.StationunitDetailPage() pay_detail_page = paydetail.PayDetailPage() promote_detail_page = promotedetail.PromoteDetailPage() @skip("js scroll screen always error pause this case for now") @retrying.retry(retry_on_exception=retry_if_timeout_exception, stop_max_attempt_number=2) def test_case(self): self.util_init(__file__) self.testcaseinfo.starttime = time.strftime("%Y-%m-%d %H:%M:%S") if self.flag > 1: self.setUp() try: # print self.case_name self.step = "convert to user manage page" self.logger.info(self.step) self.convert_URL = urldata.URLData().get_user_manage_page_url() self.convert_to_url(self.convert_URL) self.wait_url_to_be(self.convert_URL) self.step = "input phone" self.logger.info(self.step) self.wait_visable(self.user_manage_page.phone_text_box) self.fill(self.user_manage_page.phone_text_box, self.phone_value) self.step = "click query" self.logger.info(self.step) self.click(self.user_manage_page.query_user_button) self.step = "click username" self.logger.info(self.step) self.wait_clickable(self.user_manage_page.user_username) self.click(self.user_manage_page.user_username) self.switch_handel() self.step = "screen scroll" self.logger.info(self.step) js = "document.getElementsByClassName('list_details historyOrderBox')[0].scrollIntoView(true)" self.driver.execute_script(js) self.step = "click history order's order link" self.logger.info(self.step) self.wait_clickable(self.user_detail_page.history_order_order) self.click(self.user_detail_page.history_order_order) self.step = "match order page theme" self.logger.info(self.step) self.wait_visable(self.order_detail_page.order_detail_theme) self.assertEqual("订单详情", self.get_text_Infor(self.order_detail_page.order_detail_theme), "订单链接不匹配") self.back() self.step = "screen scroll" self.logger.info(self.step) js = "document.getElementsByClassName('list_details historyOrderBox')[0].scrollIntoView(true)" self.driver.execute_script(js) self.step = "click history order's unit link" self.logger.info(self.step) self.wait_clickable(self.user_detail_page.history_order_unit) self.click(self.user_detail_page.history_order_unit) self.switch_handel() self.step = "match unit page theme" self.logger.info(self.step) self.wait_visable(self.stationunit_detail_page.unit_detail_theme) self.assertEqual("仓位详情", self.get_text_Infor(self.stationunit_detail_page.unit_detail_theme), "仓位链接不匹配") self.driver.back() self.step = "screen scroll" self.logger.info(self.step) js = "document.getElementsByClassName('list_details historyOrderBox')[0].scrollIntoView(true)" self.driver.execute_script(js) self.step = "click history order's contract link" self.logger.info(self.step) self.wait_clickable(self.user_detail_page.history_order_contract) self.click(self.user_detail_page.history_order_contract) self.switch_handel() self.step = "match contract page theme" self.logger.info(self.step) self.wait_visable(self.contract_detail_page.contact_detail_theme) self.assertEqual("合同详情", self.get_text_Infor(self.contract_detail_page.contact_detail_theme), "合同链接") self.driver.back() self.step = "screen scroll" self.logger.info(self.step) js = "document.getElementsByClassName('list_details historyOrderBox')[0].scrollIntoView(true)" self.driver.execute_script(js) self.step = "click history order's payid link" self.logger.info(self.step) self.wait_clickable(self.user_detail_page.history_order_payid) self.click(self.user_detail_page.history_order_payid) self.switch_handel() self.step = "match payid page theme" self.logger.info(self.step) self.wait_visable(self.pay_detail_page.pay_detail_theme) self.assertEqual("支付信息", self.get_text_Infor(self.pay_detail_page.pay_detail_theme), "支付链接不匹配") self.driver.back() self.step = "screen scroll" self.logger.info(self.step) js = "document.getElementsByClassName('list_details historyOrderBox')[0].scrollIntoView(true)" self.driver.execute_script(js) self.step = "click history order's promote link" self.logger.info(self.step) self.wait_clickable(self.user_detail_page.history_order_promote) self.click(self.user_detail_page.history_order_promote) self.switch_handel() self.step = "match promote page theme" self.logger.info(self.step) self.wait_visable(self.promote_detail_page.promote_detail_theme) self.assertEqual("优惠券详情", self.get_text_Infor(self.promote_detail_page.promote_detail_theme), "优惠券链接不匹配") self.driver.back() self.testcaseinfo.result = "Pass" pass except TimeoutException: self.timeout_method() except Exception as err: self.exception_method(err) finally: self.finally_method()
def test_case(self): self.util_init(__file__) self.testcaseinfo.starttime = time.strftime("%Y-%m-%d %H:%M:%S") if self.flag > 1: self.setUp() try: self.step = "convert to overdue remind page" self.logger.info(self.step) self.convert_to_url( urldata.URLData().get_overdue_remind_page_url()) self.wait_url_to_be( urldata.URLData().get_overdue_remind_page_url()) self.step = "select company" self.logger.info(self.step) self.wait_visable(self.due_remind_page.cityList_select) self.Select(self.due_remind_page.company_select, self.company_value) self.step = "select city " self.logger.info(self.step) self.Select(self.due_remind_page.cityList_select, self.city_value) self.step = "select type " self.logger.info(self.step) self.Select(self.due_remind_page.typeList_select, self.type_value) self.step = "select station" self.logger.info(self.step) self.Select(self.due_remind_page.stationList_select, self.station_value) self.step = "select is use" self.logger.info(self.step) self.Select(self.due_remind_page.is_use_select, self.is_use_value) self.step = "click query button" self.logger.info(self.step) self.click(self.due_remind_page.query_button) self.step = "validate result" self.logger.info(self.step) self.wait_visable(self.due_remind_page.unit_link) after_station = self.get_text_Infor(self.due_remind_page.unit_link) after_is_use = self.get_text_Infor( self.due_remind_page.overdue_statu) self.assertEquals(self.is_use_value, after_is_use, "逾期状态结果不匹配") if self.station_value not in after_station: raise Exception("分店不匹配") self.step = "click and validate contract link" self.logger.info(self.step) self.click(self.due_remind_page.contract_link) self.switch_handel() self.wait_visable( contractdetail.ContactDetailPage().contact_detail_theme) after_theme = self.get_text_Infor( contractdetail.ContactDetailPage().contact_detail_theme) self.assertEquals("合同详情", after_theme, "合同详情链接不匹配") self.driver.close() self.switch_handel() self.step = "click and validate user link" self.logger.info(self.step) self.click(self.due_remind_page.user_link) self.switch_handel() self.wait_visable(userdetail.UserDetailPage().user_detail_theme) after_theme = self.get_text_Infor( userdetail.UserDetailPage().user_detail_theme) self.assertEquals("用户详情", after_theme, "用户详情链接不匹配") self.driver.close() self.switch_handel() self.step = "click and validate stationunit link" self.logger.info(self.step) self.click(self.due_remind_page.unit_link) self.switch_handel() self.wait_visable( stationunitdetail.StationunitDetailPage().unit_detail_theme) after_theme = self.get_text_Infor( stationunitdetail.StationunitDetailPage().unit_detail_theme) self.assertEquals("仓位详情", after_theme, "仓位详情链接不匹配") self.testcaseinfo.result = "Pass" pass except TimeoutException: self.timeout_method() except Exception as err: self.exception_method(err) finally: self.finally_method()
class OMS(AbTemplate): # sometimes run the file name is file.py sometimes is file.pyc so we need replace by this way # file_name = os.path.basename(__file__).replace(".pyc", "").replace(".py", "_case") # case_info = file_name.split("_", 1) # case_id = case_info[0] # case_name = case_info[1] # testcaseinfo = testcaseinfo.TestCaseInfo(case_id, case_name, "功能测试") # logger = noteLog.Loggger(case_name) # testcaseinfo.setLogPath(logger.rel_file) # case info company_value = "新海汇" area_value = "北京市" unit_type_value = "迷你仓" station_value = "双井国贸" unit_value = "双井 A1" order_type_value = "续仓" order_statu_value = "完成" pay_method_value = "微信" order_id_value = "1007082102089340" start_date_value = "2019-07-20" end_date_value = "2019-08-23" # page info order_manage_page = ordermanage.orderManagePage() order_detail_page = orderdetail.OrderDetail() unit_detail_page = stationunitdetail.StationunitDetailPage() pay_detail_page = paydetail.PayDetailPage() contact_detail_page = contractdetail.ContactDetailPage() user_detail_page = userdetail.UserDetailPage() @retrying.retry(retry_on_exception=retry_if_timeout_exception, stop_max_attempt_number=2) def test_case_by(self): self.util_init(__file__) self.testcaseinfo.name = self.case_name + "_by" self.testcaseinfo.starttime = time.strftime("%Y-%m-%d %H:%M:%S") if self.flag > 1: self.setUp() try: self.step = "convert to order manage page" self.logger.info(self.step) self.convert_URL = urldata.URLData().get_order_manage_page_url() self.convert_to_url(self.convert_URL) self.wait_url_to_be(self.convert_URL) self.step = "select company" self.logger.info(self.step) self.wait_visable(self.order_manage_page.company_select) self.Select(self.order_manage_page.company_select, self.company_value) self.step = "select area" self.logger.info(self.step) self.Select(self.order_manage_page.area_select, self.area_value) self.step = "select unit type" self.logger.info(self.step) self.Select(self.order_manage_page.unit_type_select, self.unit_type_value) self.step = "select station" self.logger.info(self.step) self.Select(self.order_manage_page.manage_station_select, self.station_value) self.step = "fill unit" self.logger.info(self.step) self.fill(self.order_manage_page.unit_box, self.unit_value) self.step = "select order type" self.logger.info(self.step) self.Select(self.order_manage_page.order_type_select, self.order_type_value) self.step = "select order statu" self.logger.info(self.step) self.Select(self.order_manage_page.order_statu_select, self.order_statu_value) self.step = "select pay method" self.logger.info(self.step) self.Select(self.order_manage_page.pay_method_select, self.pay_method_value) self.step = "fill start date time" self.logger.info(self.step) self.clear(self.order_manage_page.manage_start_time) self.fill(self.order_manage_page.manage_start_time, self.start_date_value) self.step = "fill end date time" self.logger.info(self.step) self.clear(self.order_manage_page.manage_end_time) self.fill(self.order_manage_page.manage_end_time, self.end_date_value) self.step = "fill order value" self.logger.info(self.step) self.fill(self.order_manage_page.order_id_box, self.order_id_value) self.step = "click query" self.logger.info(self.step) self.click(self.order_manage_page.query_button) self.step = "match order id" self.logger.info(self.step, 10) self.assertEqual( self.get_text_Infor(self.order_manage_page.orider_link), self.order_id_value, "查询结果订单号不匹配") self.step = "match unit type" self.logger.info(self.step) self.assertEqual( self.get_text_Infor(self.order_manage_page.unit_type_info), self.order_type_value, "订单类型不匹配") self.step = "click order link" self.logger.info(self.step) self.wait_clickable(self.order_manage_page.orider_link) self.click(self.order_manage_page.orider_link) self.switch_handel() self.step = "match order link" self.logger.info(self.step) self.wait_visable(self.order_detail_page.order_detail_theme) now_theme = self.get_text_Infor( self.order_detail_page.order_detail_theme) self.assertEquals(now_theme, "订单详情", "订单链接跳转不匹配") self.driver.close() self.switch_handel() self.step = "click unit link" self.logger.info(self.step) self.wait_clickable(self.order_manage_page.unit_link) self.click(self.order_manage_page.unit_link) self.switch_handel() self.step = "match unit link" self.logger.info(self.step) self.wait_visable(self.unit_detail_page.unit_detail_theme) now_theme = self.get_text_Infor( self.unit_detail_page.unit_detail_theme) self.assertEquals(now_theme, "仓位详情", "仓位链接跳转不匹配") self.driver.close() self.switch_handel() self.step = "click user link" self.logger.info(self.step) self.wait_clickable(self.order_manage_page.user_link) self.click(self.order_manage_page.user_link) self.switch_handel() self.step = "match user link" self.logger.info(self.step) self.wait_visable(self.user_detail_page.user_detail_theme) now_theme = self.get_text_Infor( self.user_detail_page.user_detail_theme) self.assertEquals(now_theme, "用户详情", "用户链接跳转不匹配") self.driver.close() self.switch_handel() self.step = "click contract link" self.logger.info(self.step) self.wait_clickable(self.order_manage_page.contract_link) self.click(self.order_manage_page.contract_link) self.switch_handel() self.step = "match contract link" self.logger.info(self.step) self.wait_visable(self.contact_detail_page.contact_detail_theme) now_theme = self.get_text_Infor( self.contact_detail_page.contact_detail_theme) self.assertEquals("合同详情", now_theme, "合同链接跳转不匹配") self.driver.close() self.switch_handel() self.step = "click pay link" self.logger.info(self.step) self.wait_clickable(self.order_manage_page.payment_link) self.click(self.order_manage_page.payment_link) self.switch_handel() self.step = "match pay link" self.logger.info(self.step) self.wait_visable(self.pay_detail_page.pay_detail_theme) now_theme = self.get_text_Infor( self.pay_detail_page.pay_detail_theme) self.assertEquals("支付信息", now_theme, "支付链接跳转不匹配") self.driver.close() self.switch_handel() self.testcaseinfo.result = "Pass" pass except TimeoutException: self.timeout_method() except Exception as err: self.exception_method(err) finally: self.finally_method() @retrying.retry(retry_on_exception=retry_if_timeout_exception, stop_max_attempt_number=2) def test_case_all(self): self.util_init(__file__) self.testcaseinfo.name = self.case_name + "_all" self.testcaseinfo.starttime = time.strftime("%Y-%m-%d %H:%M:%S") if self.flag > 1: self.setUp() try: self.step = "convert to order manage page" self.logger.info(self.step) self.convert_URL = urldata.URLData().get_order_manage_page_url() self.convert_to_url(self.convert_URL) self.wait_url_to_be(self.convert_URL) self.step = "select company" self.logger.info(self.step) self.wait_clickable(self.order_manage_page.query_button) self.Select(self.order_manage_page.company_select, self.company_value) self.step = "click query" self.logger.info(self.step) self.click(self.order_manage_page.query_button) self.step = "match result" self.logger.info(self.step, 10) if not self.find_element(self.order_manage_page.user_phone_info): raise Exception("not find result") self.testcaseinfo.result = "Pass" except TimeoutException: self.timeout_method() except Exception as err: self.exception_method(err) finally: self.finally_method()
class OMS(AbTemplate): # sometimes run the file name is file.py sometimes is file.pyc so we need replace by this way # file_name = os.path.basename(__file__).replace(".pyc", "_case").replace(".py", "_case") # case_info = file_name.split("_", 1) # case_id = case_info[0] # case_name = case_info[1] # testcaseinfo = testcaseinfo.TestCaseInfo(case_id, case_name, "功能测试") # logger = noteLog.Loggger(case_name) # testcaseinfo.setLogPath(logger.rel_file) # case info lock_id_value = "00124b000f2927c3" position = "双井 C4" station_value = "双井国贸" # page info stationunit_manage_page = stationunitmanage.StationunitManagePage() stationunit_detail_page = stationunitdetail.StationunitDetailPage() @retrying.retry(retry_on_exception=retry_if_timeout_exception, stop_max_attempt_number=2) def test_case(self): self.util_init(__file__) self.testcaseinfo.starttime = time.strftime("%Y-%m-%d %H:%M:%S") if self.flag > 1: self.setUp() try: self.step = "convert to station manage page" self.logger.info(self.step) self.convert_URL = urldata.URLData().get_station_manage_page_url() self.convert_to_url(self.convert_URL) self.wait_url_to_be(self.convert_URL) self.step = "fill position" self.logger.info(self.step) self.wait_visable(self.stationunit_manage_page.position_box) self.fill(self.stationunit_manage_page.position_box, self.position) self.step = "select station" self.logger.info(self.step) self.Select(self.stationunit_manage_page.station_select, self.station_value) self.step = "click query" self.logger.info(self.step) self.click(self.stationunit_manage_page.query_button) self.step = "click position" self.logger.info(self.step) self.wait_clickable(self.stationunit_manage_page.position_link) self.click(self.stationunit_manage_page.position_link) self.switch_handel() self.step = "click lock change button" self.logger.info(self.step) self.click(self.stationunit_detail_page.change_lock_button) self.step = "fill new lock sn" self.logger.info(self.step) self.wait_visable(self.stationunit_detail_page.newlock_box) self.fill(self.stationunit_detail_page.newlock_box, self.lock_id_value) self.step = "click confirm button" self.logger.info(self.step) self.click(self.stationunit_detail_page.newlock_confirm_button) self.step = "validate dialog info" self.wait_visable(self.stationunit_detail_page.wrong_info) dialog_info = self.get_text_Infor(self.stationunit_detail_page.wrong_info) self.assertEqual(dialog_info, "换锁成功", "弹窗信息提示错误,换锁失败") self.testcaseinfo.result = "Pass" pass except TimeoutException: self.timeout_method() except Exception as err: self.exception_method(err) finally: self.finally_method()
class OMS(AbTemplate): # sometimes run the file name is file.py sometimes is file.pyc so we need replace by this way # file_name = os.path.basename(__file__).replace(".pyc", "_case").replace(".py", "_case") # case_info = file_name.split("_", 1) # case_id = case_info[0] # case_name = case_info[1] # testcaseinfo = testcaseinfo.TestCaseInfo(case_id, case_name, "功能测试") # logger = noteLog.Loggger(case_name) # testcaseinfo.setLogPath(logger.rel_file) # case info height_value = random.randint(10, 50) price_value = random.randint(1000, 5000) position = "双井 C4" station_value = "双井国贸" # page info stationunit_manage_page = stationunitmanage.StationunitManagePage() stationunit_detail_page = stationunitdetail.StationunitDetailPage() @retrying.retry(retry_on_exception=retry_if_timeout_exception, stop_max_attempt_number=2) def test_case(self): self.util_init(__file__) self.testcaseinfo.starttime = time.strftime("%Y-%m-%d %H:%M:%S") if self.flag > 1: self.setUp() try: self.step = "convert to station manage page" self.logger.info(self.step) self.convert_URL = urldata.URLData().get_station_manage_page_url() self.convert_to_url(self.convert_URL) self.wait_url_to_be(self.convert_URL) self.step = "fill station" self.logger.info(self.step) self.wait_visable(self.stationunit_manage_page.position_box) self.fill(self.stationunit_manage_page.position_box, self.position) self.step = "select station" self.logger.info(self.step) self.Select(self.stationunit_manage_page.station_select, self.station_value) self.step = "click query" self.logger.info(self.step) self.click(self.stationunit_manage_page.query_button) self.step = "click position" self.logger.info(self.step) self.wait_clickable(self.stationunit_manage_page.position_link) self.click(self.stationunit_manage_page.position_link) self.switch_handel() self.step = "click modify button" self.logger.info(self.step) self.click(self.stationunit_detail_page.modify_unit_button) self.wait_visable(self.stationunit_detail_page.volume_info) self.volume_value = float('%.2f' % float( float( self.get_text_Infor( self.stationunit_detail_page.volume_info)) + random.uniform(-0.1, 0.1))) self.step = "clear height value" self.logger.info(self.step) self.find_element(self.stationunit_detail_page.height_box).clear() self.step = "clear volume value" self.logger.info(self.step) self.find_element(self.stationunit_detail_page.volume_box).clear() self.step = "clear price value" self.logger.info(self.step) self.find_element(self.stationunit_detail_page.price_box).clear() self.step = "clear comment value" self.logger.info(self.step) self.find_element(self.stationunit_detail_page.comment_box).clear() self.step = "fill new height" self.logger.info(self.step) self.fill(self.stationunit_detail_page.height_box, self.height_value) self.step = "fill new volume" self.logger.info(self.step) self.fill(self.stationunit_detail_page.volume_box, self.volume_value) self.step = "fill new price" self.logger.info(self.step) self.fill(self.stationunit_detail_page.price_box, self.price_value) self.step = "click confirm button" self.logger.info(self.step) self.click(self.stationunit_detail_page.modify_submit_button) self.wait_a_certain_time(10) self.step = "match height value after modify" self.logger.info(self.step) new_height_value = int( self.get_text_Infor(self.stationunit_detail_page.height_info)) self.assertEquals(self.height_value, new_height_value, "高度修改后不匹配") self.step = "match volume value after modify" self.logger.info(self.step) new_volume_value = float( self.get_text_Infor(self.stationunit_detail_page.volume_info)) self.assertEquals(self.volume_value, new_volume_value, "规格修改后不匹配") self.step = "match price value after modify" self.logger.info(self.step) new_price_value = int( self.get_text_Infor(self.stationunit_detail_page.price_info)) self.assertEquals(self.price_value, new_price_value, "价格修改后不匹配") self.testcaseinfo.result = "Pass" pass except TimeoutException: self.timeout_method() except Exception as err: self.exception_method(err) finally: self.finally_method()
class OMS(AbTemplate): # file_name = os.path.basename(__file__).replace(".pyc", "_case").replace(".py", "_case") # case_info = file_name.split("_", 1) # case_id = case_info[0] # case_name = case_info[1] # testcaseinfo = testcaseinfo.TestCaseInfo(case_id, case_name, "功能测试") # logger = noteLog.Loggger(case_name) # testcaseinfo.setLogPath(logger.rel_file) # case info phone_value = "15611805853" # page info user_manage_page = usermanage.UserManagePage() user_detail_page = userdetail.UserDetailPage() order_detail_page = orderdetail.OrderDetail() contract_detail_page = contractdetail.ContactDetailPage() stationunit_detail_page = stationunitdetail.StationunitDetailPage() @retrying.retry(retry_on_exception=retry_if_timeout_exception, stop_max_attempt_number=2) def test_case(self): self.util_init(__file__) self.testcaseinfo.starttime = time.strftime("%Y-%m-%d %H:%M:%S") if self.flag > 1: self.setUp() try: # print self.case_name self.step = "convert to user manage page" self.logger.info(self.step) self.convert_URL = urldata.URLData().get_user_manage_page_url() self.convert_to_url(self.convert_URL) self.wait_url_to_be(self.convert_URL) self.step = "input phone" self.logger.info(self.step) self.wait_visable(self.user_manage_page.phone_text_box) self.fill(self.user_manage_page.phone_text_box, self.phone_value) self.step = "click query" self.logger.info(self.step) self.click(self.user_manage_page.query_user_button) self.step = "click username" self.logger.info(self.step) self.wait_clickable(self.user_manage_page.user_username) self.click(self.user_manage_page.user_username) self.switch_handel() self.step = "click contract history's contract link" self.logger.info(self.step) self.wait_clickable( self.user_detail_page.contract_history_contract) self.click(self.user_detail_page.contract_history_contract) self.step = "match contract page theme" self.logger.info(self.step) self.wait_visable(self.contract_detail_page.contact_detail_theme) self.assertEqual( "合同详情", self.get_text_Infor( self.contract_detail_page.contact_detail_theme), "合同链接不匹配") self.driver.back() self.step = "click contract history's order link" self.logger.info(self.step) # target=self.find_element(self.user_detail_page.contract_history_order) # self.driver.execute_script("arguments[0].scrollIntoView();",target) self.wait_clickable(self.user_detail_page.contract_history_order) self.click(self.user_detail_page.contract_history_order) self.step = "match order page theme" self.logger.info(self.step) self.wait_visable(self.order_detail_page.order_detail_theme) self.assertEqual( "订单详情", self.get_text_Infor(self.order_detail_page.order_detail_theme), "订单链接不匹配") self.back() self.step = "click contract history's unit link" self.logger.info(self.step) self.wait_clickable(self.user_detail_page.contract_history_unit) self.click(self.user_detail_page.contract_history_unit) self.switch_handel() self.step = "match unit page theme" self.logger.info(self.step) self.wait_visable(self.stationunit_detail_page.unit_detail_theme) self.assertEqual( "仓位详情", self.get_text_Infor( self.stationunit_detail_page.unit_detail_theme), "仓位链接不匹配") self.testcaseinfo.result = "Pass" pass except TimeoutException: self.timeout_method() except Exception as err: self.exception_method(err) finally: self.finally_method()
class OMS(AbTemplate): # sometimes run the file name is file.py sometimes is file.pyc so we need replace by this way # file_name = os.path.basename(__file__).replace(".pyc", "_case").replace(".py", "_case") # case_info = file_name.split("_", 1) # case_id = case_info[0] # case_name = case_info[1] # testcaseinfo = testcaseinfo.TestCaseInfo(case_id, case_name, "功能测试") # logger = noteLog.Loggger(case_name) # testcaseinfo.setLogPath(logger.rel_file) # case info position = "双井 C4" station_value = "双井国贸" # page info stationunit_manage_page = stationunitmanage.StationunitManagePage() stationunit_detail_page = stationunitdetail.StationunitDetailPage() history_order_page = orderhistory.HistoryOrderPage() @retrying.retry(retry_on_exception=retry_if_timeout_exception, stop_max_attempt_number=2) def test_case(self): self.util_init(__file__) self.testcaseinfo.starttime = time.strftime("%Y-%m-%d %H:%M:%S") if self.flag > 1: self.setUp() try: self.step = "convert to station manage page" self.logger.info(self.step) self.convert_URL = urldata.URLData().get_station_manage_page_url() self.convert_to_url(self.convert_URL) self.wait_url_to_be(self.convert_URL) self.step = "fill station" self.logger.info(self.step) self.wait_visable(self.stationunit_manage_page.position_box) self.fill(self.stationunit_manage_page.position_box, self.position) self.step = "select station" self.logger.info(self.step) self.Select(self.stationunit_manage_page.station_select, self.station_value) self.step = "click query" self.logger.info(self.step) self.click(self.stationunit_manage_page.query_button) self.step = "click position" self.logger.info(self.step) self.wait_clickable(self.stationunit_manage_page.position_link) self.click(self.stationunit_manage_page.position_link) self.switch_handel() self.step = "click history order" self.logger.info(self.step) self.wait_clickable( self.stationunit_detail_page.order_history_button) self.click(self.stationunit_detail_page.order_history_button) self.step = "record order link" self.logger.info(self.step) self.wait_visable(self.history_order_page.order_link) url_should = self.find_element( self.history_order_page.order_link).get_attribute('href') self.step = "click order link" self.logger.info(self.step) self.click(self.history_order_page.order_link) self.step = "contrast order link" self.logger.info(self.step) self.wait_a_certain_time(5) url_now = self.driver.current_url self.assertEquals(url_should, url_now, "订单链接不匹配") self.step = "back and record contract link" self.logger.info(self.step) self.driver.back() self.wait_visable(self.history_order_page.contract_link) url_should = self.find_element( self.history_order_page.contract_link).get_attribute("href") self.step = "click contract" self.logger.info(self.step) self.click(self.history_order_page.contract_link) self.step = "contrast contract link" self.logger.info(self.step) self.wait_a_certain_time(5) url_now = self.driver.current_url self.assertEquals(url_now, url_should, "合同链接不匹配") self.testcaseinfo.result = "Pass" pass except TimeoutException: self.timeout_method() except Exception as err: self.exception_method(err) finally: self.finally_method()