def test_cash_payment(setup_module): enter_workbench.workbench_payment() # 输入手机号码, enter_workbench.workbench_inputPhone() enter_workbench.input_oilgunNo(enter_workbench.get_diesegunNo()) oilPrice=round(random.random()*100,2) #加油金额随机数字,保留2个小数位 enter_workbench.input_oilPrice(oilPrice) #输入加油金额 enter_workbench.clear_coupon() # 获取提交订单时计算的实收金额 receivepayment = enter_workbench.get_receivepayment() print('实收金额:', receivepayment) # 获取提交订单时计算的优惠金额 discount = enter_workbench.get_discount() print('提交订单时计算的优惠金额', discount) # enter_workbench.input_cash_receipt() Amount_Collected=enter_workbench.get_cash_receipt() print('提交订单时计算的收款金额', Amount_Collected) PageAction.capture_screen() enter_workbench.Cash_payment_click() enter_workbench.click_pay() if PageAction.assert_word('现金支付成功'): enter_workbench.close_success_pay_Popup() enter_workbench.close_payment_windows() print('现金支付流程成功') else: PageAction.assert_word('现金支付失败') enter_workbench.close_fail_pay_Popup() enter_workbench.close_payment_windows() print('现金支付流程失败') error('现金支付流程失败')
def test_Balance_payment(setup_module): enter_workbench.workbench_payment() #输入手机号码, enter_workbench.Balance_payment_click() # 支付方式按钮:余额支付 enter_workbench.input_oilgunNo(enter_workbench.get_diesegunNo()) # 输入汽油枪号 #[0::2]-->取奇数位包含列表末位,[0:-1:2]-->取奇数位不包含末位 before_dieselBalance, before_commonlBalance = enter_workbench.workbench_inputPhone( )[0::2] #加油前-获取汽油余额+通用余额 if not (before_dieselBalance and before_commonlBalance): oilPrice = random.randint(2, 10) else: oilPrice = float(before_dieselBalance) + float( before_commonlBalance) + 1 #加油金额>余额 enter_workbench.input_oilPrice(oilPrice) #输入加油金额 enter_workbench.clear_coupon() # 获取提交订单时计算的实收金额 receivepayment = enter_workbench.get_receivepayment() print('实收金额:', receivepayment) # 获取提交订单时计算的优惠金额 discount = enter_workbench.get_discount() print('提交订单时计算的优惠金额', discount) PageAction.capture_screen() # 收款操作 PageAction.roll_bottom() enter_workbench.click_pay() if PageAction.assert_word('余额支付失败'): print('余额不足支付失败,与预期一致') enter_workbench.close_fail_pay_Popup() enter_workbench.close_payment_windows() else: PageAction.assert_word('余额支付成功') enter_workbench.close_payment_windows() print('余额不足不该支持成功,与预期不一致') error('余额不足不该支持成功,与预期不一致')
def test_balance_payment(setup_module): try: enter_workbench.workbench_payment() #输入手机号码, enter_workbench.Balance_payment_click() # 支付方式按钮:余额支付 enter_workbench.input_oilgunNo( enter_workbench.get_diesegunNo()) # 输入汽油枪号 # 加油前-获取汽油余额和通用余额 before_dieselBalance, before_commonlBalance = enter_workbench.workbench_inputPhone( )[0::2] print('加油前-获取汽油余额和通用余额', before_dieselBalance, before_commonlBalance) if float(before_dieselBalance) > 0: oilPrice = round((float(before_dieselBalance) / 8) * 100 / 100.0, 2) #取加油金额=汽油余额的1/4 elif float(before_commonlBalance) > 0: oilPrice = round((float(before_commonlBalance) / 8) * 100 / 100.0, 2) # 取加油金额=通用余额的1/4 # oilPrice=0.1 enter_workbench.input_oilPrice(oilPrice) #输入加油金额 enter_workbench.clear_coupon() # 获取提交订单时计算的实收金额 receivepayment = enter_workbench.get_receivepayment() print('实收金额:', receivepayment) # 获取提交订单时计算的优惠金额 discount = enter_workbench.get_discount() print('提交订单时计算的优惠金额', discount) # PageAction.capture_screen() # 收款操作 PageAction.roll_bottom() enter_workbench.click_pay() if PageAction.assert_word('余额支付成功') == True: enter_workbench.close_success_pay_Popup() #断言部分: map(lambda x :float(x) ,L) Balance_list = enter_workbench.workbench_inputPhone( ) #返回list包含 会员各种类型的余额文本 print('Balance_list', Balance_list) after_dieselBalance, after_gaslBalance, after_commonlBalance = map( lambda x: float(x), Balance_list) #金额文本转成浮点金额 except_remain_Balance = round( (((float(before_dieselBalance) - oilPrice) * 100) / 100.0), 2) # 预期剩余汽油余额 print('原汽油余额:%s,应收金额:%s,预期剩余汽油金额:%s' % (before_dieselBalance, receivepayment, except_remain_Balance)) # 断言会员余额加油前后变化 if not except_remain_Balance == after_dieselBalance: PageAction.capture_error_screen() error('实际剩余汽油余额: %s 跟预期剩余汽油余额: %s不一致' % ( after_dieselBalance, except_remain_Balance, )) enter_workbench.close_payment_windows() payed = enter_workbench.get_order_realpay() print('订单记录的实收金额:', payed) if not receivepayment == payed: PageAction.capture_error_screen() error('订单记录的实收金额:%s与付款实付金额:%s不一致' % (payed, receivepayment)) order_discount = enter_workbench.get_order_discount() print('订单记录的优惠金额:', order_discount) if not order_discount == discount: PageAction.capture_error_screen() error('订单的优惠金额:%s与付款优惠金额:%s不一致' % (order_discount, discount)) else: PageAction.assert_word('余额支付失败') print('余额支付失败') enter_workbench.close_fail_pay_Popup() enter_workbench.close_payment_windows() error('余额支付失败') else: print('通用余额,汽油余额都不足无法进行余额支付') PageAction.capture_error_screen() error('通用余额,汽油余额都不足无法进行余额支付') except Exception as e: raise e print('过程执行失败')