def setUpClass(cls): cls.carNum = ChargesPage().create_carNum() cls.U = UncertifiedCarPage(cls.carNum) ChargesPage().binding_carCode(cls.carNum) cls.A = ApiCase(carNum=cls.carNum) cls.A.car_run_inside() Pomp().open_monthTicket(cls.carNum)
def test_add_and_del_carNum(self): """ 用例描述:添加-删除-车牌号 """ P = ChargesPage() carCode = P.create_carNum() assert P.binding_carCode(carCode) == True assert P.del_carCode(carCode) == True
def test_payleave_account(self): """ 用例描述:付费离场(余额支付) """ A = ApiCase(carNum=Config().common_carNum) A.car_run_inside() P = ChargesPage() P.pay_charges(Config().common_carNum) result = P.submit_pay() assert result == True A.car_run_outside()
def test_setting_often_carNum(self): """ 用例描述:设置常用车牌 """ P = ChargesPage() carCode = P.create_carNum() P.binding_carCode(carCode) P.set_often_carNum(carCode) result = P.set_often_carNum(Config().common_carNum) P.del_carCode(carCode) assert result == True
class UncertifiedCarPage(PocoBase): """未认证车辆界面""" def __init__(self, carNum): self.P = ChargesPage() self.carNum = carNum super(UncertifiedCarPage, self).__init__() def find_uncertified_warm(self): """返回车牌下方验证提醒""" self.P.choose_carCode(self.carNum) carCode = self.P.carNum_transform(self.carNum).strip() text = self.poco(carCode + "车辆未认证,点击认证").get_name() return text def find_uncertified_carPicture_warn(self): """返回进场图片会弹出要提示认证的提醒""" return self.get_pocoValue("查看进场图片需要行驶证认证", "进场图片") def find_uncertified_lock_warn(self): """返回上锁弹出要提示认证的提醒""" return self.get_pocoValue("锁车需要行驶证认证", "锁车") def find_uncertified_parkingName(self): """返回停车场名为“***停车场”""" return self.get_pocoValue("***停车场") def Uncertified_monthTicketDetail_authorize_warn(self, carNum): """返回月票详情和授权会弹出要认证提醒""" self.click(self.poco("月票")) home() start_app("com.tencent.mm") carVaule = self.getName(self.poco(nameMatches="车牌号:.*")) for num in range(0, 2): if carNum in carVaule: self.click(self.poco("访客授权")) text = self.getName(self.poco("访客授权需行驶证认证")) self.screenshot("提示框界面") self.click(self.poco("取消 ")) return text # break else: self.swipe_poco(self.poco(nameMatches="车牌号.*"), [-0.5, 0]) home() start_app("com.tencent.mm") def get_pocoValue(self, check_poco, click_poco=None): self.P.choose_carCode(self.carNum) if click_poco: self.click(self.poco(click_poco)) self.screenshot("提示框界面") return self.getName(self.poco(check_poco))
def visitor_authorization(self, carNum, time="once"): self.login_monthTicketPage() self.click(self.poco("访客授权")) self.click(self.poco("继续授权")) self.click(self.poco("添加车牌")) ChargesPage().keySet_carNum(carNum) self.screenshot("授权界面") self.click(self.poco("确认授权")) if time == "once": self.touch( Template(BASE_DIR + r"\img\车辆授权次数.png", threshold=0.7, target_pos=7, rgb=False, record_pos=(0.01, 0.08), resolution=(1080, 1920))) else: self.touch( Template(BASE_DIR + r"\img\车辆授权次数.png", threshold=0.7, target_pos=9, rgb=False, record_pos=(0.01, 0.08), resolution=(1080, 1920))) sleep(3) if self.poco("不限").exists(): self.screenshot("授权结果界面") return "不限次数" else: self.screenshot("授权结果界面") return "授权一次"
def test_monthTicket_detail(self): """ 用例描述:点击月票详情 """ result = self.M.check_details() assert result == "自动化测试停车场" ChargesPage().back(1)
class TestPayChargesWeiXin(unittest.TestCase): """微信支付案例""" def setUp(self): self.P = ChargesPage() self.carCode = self.P.create_carNum() def tearDown(self): self.P.back(3) @getFunName @allure.story("付费离场(微信支付)") def test_payleave_weixin(self): """ 用例描述:付费离场(微信支付) """ A = ApiCase(carNum=Config().common_carNum) A.car_run_inside() self.P.pay_charges(Config().common_carNum) result = self.P.submit_pay(type="微信") assert result == True A.pay_charge() A.car_run_outside() @getFunName @allure.story("代缴停车费") def test_pay_another(self): """ 用例描述:代缴停车费 """ A = ApiCase(carNum=self.carCode) A.car_run_inside() result = self.P.pay_with_another(self.carCode) assert result == True A.pay_charge() A.car_run_outside()
def renew_monthTicket(self): self.login_monthTicketPage() self.click(self.poco("续期")) self.touch( Template(BASE_DIR + r"\img\勾选已阅读.png", threshold=0.7, target_pos=4, resolution=(1080, 1920))) self.screenshot("月票续约付款界面") self.click(self.poco("确认支付")) return ChargesPage().submit_pay()
def test_lock_and_unlock(self): """ 用例描述:车辆锁定-解锁 """ A = ApiCase(carNum=Config().common_carNum) A.car_run_inside() P = ChargesPage() result = P.lock_car(Config().common_carNum) assert result == True P.unlock_car(Config().common_carNum) A.pay_charge() A.car_run_outside() P.web_refresh()
def set_operation(self,operation_value,expect_value): ChargesPage().web_refresh() self.login_seetingPage() self.touch( Template(BASE_DIR + r"\img\\" + operation_value + ".png", threshold=0.70, target_pos=6, rgb=True, record_pos=(-0.012, -0.481), resolution=(1080, 1920))) if self.exists_poco(self.poco("设置成功")): if self.exists_pic(Template(BASE_DIR + r"\img\\" + expect_value + ".png", threshold=0.70, target_pos=6, rgb=True, record_pos=(-0.012, -0.481), resolution=(1080, 1920))): set_message_remind = True self.screenshot(expect_value + '界面') else: pass else: set_message_remind = False self.screenshot("设置失败") return set_message_remind
def submit_monthTicket(self, parking): self.click(self.poco("请选择停车场")) self.click(self.poco(parking)) self.click(self.poco("车牌号")) self.touch( Template(BASE_DIR + r"\img\选择车牌.png", target_pos=8, record_pos=(0.02, 0.529), resolution=(1080, 1920))) self.touch( Template(BASE_DIR + r"\img\勾选已阅读.png", threshold=0.7, target_pos=4, resolution=(1080, 1920))) self.screenshot("月票付款界面") self.click(self.poco("确认支付")) return ChargesPage().submit_pay()
def tearDownClass(cls): ChargesPage().del_carCode(cls.carNum) cls.A.car_run_outside() Pomp().refund_monthTicket(carNum=cls.carNum)
def setUp(self): self.P = ChargesPage()
class TestAddTypeCarNum(unittest.TestCase): def setUp(self): self.P = ChargesPage() def tearDown(self): self.P.del_carCode(self.carCode) self.A.car_run_outside() @getFunName @allure.story("添加黄牌车-进出场缴费一次") def test_add_yellowCarNum_and_pay(self): """ 用例描述:添加黄牌车-进出场缴费一次 """ self.carCode = self.P.create_carNum() self.A = ApiCase(carNum=self.carCode + "黄") self.A.car_run_inside() result = self.P.binding_carCode(self.carCode, carType="黄牌") self.P.pay_charges(self.carCode) self.P.submit_pay() assert result == True @getFunName @allure.story("添加白牌车-进出场缴费一次") def test_add_whiteCarNum_and_pay(self): """ 用例描述:添加白牌车-进出场缴费一次 """ self.carCode = self.P.create_carNum() self.A = ApiCase(carNum=self.carCode + "白") self.A.car_run_inside() assert self.P.binding_carCode(self.carCode, carType="白牌") == True self.P.pay_charges(self.carCode) self.P.submit_pay() @getFunName @allure.story("添加黑牌车-进出场缴费一次") def test_add_blackCarNum_and_pay(self): """ 用例描述:添加黑牌车-进出场缴费一次 """ self.carCode = self.P.create_carNum() self.A = ApiCase(carNum=self.carCode + "黑") self.A.car_run_inside() assert self.P.binding_carCode(self.carCode, carType="黑牌") == True self.P.pay_charges(self.carCode) self.P.submit_pay() @getFunName @allure.story("添加新能源牌车-进出场缴费一次") def test_add_greenCarNum_and_pay(self): """ 用例描述:添加新能源牌车-进出场缴费一次 """ self.carCode = self.P.create_carNum(carType="新能源") self.A = ApiCase(carNum=self.carCode) self.A.car_run_inside() assert self.P.binding_carCode(self.carCode, carType="新能源") == True self.P.pay_charges(self.carCode) self.P.submit_pay() @getFunName @allure.story("添加民航车-进出场缴费一次") def test_add_flightCarNum_and_pay(self): """ 用例描述:添加民航车-进出场缴费一次 """ self.carCode = self.P.create_carNum(carType="民航") self.A = ApiCase(carNum=self.carCode) self.A.car_run_inside() assert self.P.binding_carCode(self.carCode, carType="民航") == True self.P.pay_charges(self.carCode) self.P.submit_pay()
def __init__(self, carNum): self.P = ChargesPage() self.carNum = carNum super(UncertifiedCarPage, self).__init__()
def setUpClass(cls): cls.A = ChargesPage() cls.M = PayMonthTicketPage()
def setUp(self): self.P = ChargesPage() self.carCode = self.P.create_carNum()
def login_monthTicketPage(self): ChargesPage().web_refresh() self.click(self.poco("月票")) self.screenshot("月票界面")