class FindPwdBusiness(BaseOperation): def __init__(self, driver): super(FindPwdBusiness, self).__init__(driver) self.efg = ReadIni(file_name='findpwd_page.ini') # 找回密码界面公共方法 def findpwd_action(self, phonenum, code): logging.info(r'进入找回密码界面') self.click(self.efg.read_config("找回密码按钮")) sleep(5) logging.info('找回密码账号: %s ' % phonenum) self.type(self.efg.read_config("电话输入框"), phonenum) logging.info('输入验证码: %s' % code) self.type(self.efg.read_config("验证码输入框"), code) logging.info(r'点击下一步操作') self.click(self.efg.read_config("下一步")) sleep(5) # 修改密码界面公共方法 def modify_action(self, first, second): sleep(2) logging.info(r'进入修改密码界面') logging.info(r'第一次输入密码: %s' % first) self.type(self.efg.read_config("第一次密码输入"), first) logging.info(r'第二次输入密码: %s' % second) self.type(self.efg.read_config("第二次密码输入"), second) logging.info(r'点击提交') self.click(self.efg.read_config("提交按钮")) sleep(2) # 找回密码成功状态检查 def check_find_pwd_success_status(self): sleep(3) flag = self.is_exists(self.efg.read_config("登录按钮")) return flag # 进入修改界面错误状态检查 def check_find_pwd_fail_status(self): sleep(3) flag = self.is_exists(self.efg.read_config("下一步")) return flag # 修改密码界面状态检查 def check_modify_pwd_fail_status(self): sleep(3) flag = self.is_exists(self.efg.read_config("提交按钮")) return flag
class CashBusiness(BaseOperation): def __init__(self, driver): super(CashBusiness, self).__init__(driver) self.efg = ReadIni(file_name='cash_page.ini') def cashier_goods(self, num=None, flag=False, normal=False, good_value=None, good_discount=False, good_modify=False, offer=True, order_discount=False, order_modify=False, order_value=None, cash_type="现金", saler1=None, saler2=None): self.enter_cash() self.choose_goods_action(num=num, flag=flag) self.choose_sales(name1=saler1, name2=saler2) self.goods_modify_discount(normal=normal, good_value=good_value, good_discount=good_discount, good_modify=good_modify) self.order_modify_discount(offer=offer, order_discount=order_discount, order_modify=order_modify, order_value=order_value, cash_type=cash_type) # 下面为业务操作流 # 进入收银界面 def enter_cash(self): logging.info(r'进入收银界面') self.click(self.efg.read_config('收银按钮')) time.sleep(2) logging.info(r'点击选择已有商品') self.click_text(self.efg.read_config('选择商品')) # 选择商品action def choose_goods_action(self, num=None, goodsname1='测试商品8号', goodsnam2='测试商品3号', flag=False): if flag is False: logging.info(r'点击选择非整数价格商品') self.click_text(goodsname1) elif flag is True: logging.info(r'点击选择整数价格商品') self.click_text(goodsnam2) logging.info(r'添加商品数量') for i in range(0, num): self.click(self.efg.read_config('加减按钮')) time.sleep(1) logging.info(r'确认选择商品') self.click(self.efg.read_config('商品确认按钮')) logging.info(r'商品列表界面确认') self.click(self.efg.read_config('商品列表确认按钮')) # 选择收银员 def choose_sales(self, name1=None, name2=None): if name1 is not None: logging.info(r'进入销售员界面') self.click(self.efg.read_config('销售员选择')) logging.info(r'选择销售员') self.click_text("老板-15927169432") self.click_text(name1) if name2 is not None: self.click_text(name2) else: pass self.click(self.efg.read_config('销售确认')) else: pass # 商品打折改价action def goods_modify_discount(self, normal=False, good_value=None, good_discount=False, good_modify=False): if normal: logging.info('点击改价按钮') self.click(self.efg.read_config('改价按钮')) sleep(2) logging.info('点击改价') self.click(self.efg.read_config('改价按钮')) sleep(2) if good_modify: logging.info('点击改价tab') self.click_text('改价') logging.info('输入修改后的价格') self.type(self.efg.read_config('改价价格输入框'), good_value) elif good_discount: logging.info('输入折扣') self.type(self.efg.read_config('折扣输入框'), good_value) logging.info('点击确认') self.click(self.efg.read_config('改价确认按钮')) logging.info('点击商品确认') self.click(self.efg.read_config('商品确认按钮')) else: pass # 订单打折改价action def order_modify_discount(self, offer=True, order_discount=False, order_modify=False, order_value=None, cash_type=None): if offer: logging.info(r'去结账') self.click(self.efg.read_config('结账')) self.pay_bill_action(cash_type) else: if order_discount: logging.info(r'去结账') self.click(self.efg.read_config('结账')) logging.info(r'点击整单优惠') self.click(self.efg.read_config('优惠框')) logging.info(r'滑动') self.element_swipe_up(30, self.efg.read_config('优惠选择')) logging.info(r'确认') self.click(self.efg.read_config('优惠确认')) logging.info(r'输入折扣') self.type(self.efg.read_config('折扣输入框'), order_value) self.pay_bill_action(cash_type) if order_modify: logging.info(r'去结账') self.click(self.efg.read_config('结账')) logging.info(r'点击整单优惠') self.click(self.efg.read_config('优惠框')) logging.info(r'滑动') self.element_swipe_up(60, self.efg.read_config('优惠选择')) logging.info(r'确认') self.click(self.efg.read_config('优惠确认')) logging.info(r'输入改价后的价格') self.type(self.efg.read_config('改价输入框'), order_value) self.pay_bill_action(cash_type) # 挂单成功后销售成功action def hangup_order_cashier_action(self, num, cash_type=None): self.choose_goods_action(num) logging.info(r'点击挂单按钮') self.click(self.efg.read_config('挂单按钮')) logging.info(r'进入挂单界面') self.click(self.efg.read_config('挂单界面')) logging.info(r'选择所挂的单据') self.click_text(self.efg.read_config('商品名称')) self.pay_bill_action(cash_type) # 结账action def pay_bill_action(self, value): self.click_text(value) if value in ("现金", "银行卡"): logging.info('确认收银') self.click(self.efg.read_config('确认收款')) else: logging.info('确认收银') self.click(self.efg.read_config('支付宝微信确认收款')) sleep(3) # 检查点设置 # # 检查交易成功状态 # def check_transaction_success_status(self): # logging.info(r'检查交易成功状态') # flag = self.is_exists(self.efg.read_config('交易状态')) # return flag # # # 获取交易价格 # def get_order_price(self): # logging.info(r'获取订单金额') # price = self.get_text(self.efg.read_config('实际收款金额')) # return price # # # 获取销售单号 # def get_sales_order_num(self): # logging.info(r'获取销售单单号') # sales_order_num = self.get_text(self.efg.read_config('销售单单号')) # return sales_order_num # 获取交易后信息 def get_cash_success_information(self): flag = self.is_exists(self.efg.read_config('交易状态')) sales_order_num = self.get_text(self.efg.read_config('销售单单号')) settlement_type = self.get_text(self.efg.read_config('结算方式')) saler = self.get_text(self.efg.read_config('销售员')) customer_type = self.get_text(self.efg.read_config('客户类型')) sleep(1) # self.element_swipe_up(50, self.efg.read_config('信息框')) self.swipe_up(2000) price = self.get_text(self.efg.read_config('实际收款')) status_dict = {"status": flag, "price": price, "sales_order_num": sales_order_num, "saler": saler, "settlement_type": settlement_type, "customer_type": customer_type} return status_dict
class SalesReturnBusiness(BaseOperation): def __init__(self, driver): super(SalesReturnBusiness, self).__init__(driver) self.efg = ReadIni(file_name='salereturn_page.ini') # 进入采购退货界面 def enter_sales_return(self): logging.info(r'进入库存界面') self.click(self.efg.read_config('库存')) logging.info(r'点击进入销售退货界面') self.click_text(self.efg.read_config('销售退货按钮')) # 选择原单退货 def sales_order_selection(self): logging.info('选择原单') self.click(self.efg.read_config('原始单选择')) logging.info('点击筛选') self.click(self.efg.read_config('原单筛选按钮')) # 单据筛选 def filter_order(self, keyword=None, settlement=None, seller_name=None, returned=None, status=None): if keyword is not None: logging.info(r'输入单号') self.type(self.efg.read_config('关键字'), keyword) if settlement is not None: logging.info('输入开始时间') self.click(self.efg.read_config('结算方式')) self.click_text(settlement) if seller_name is not None: logging.info('选择销售员') self.click(self.efg.read_config('选择销售员')) self.click_text(seller_name) if returned is not None: logging.info('选择退货状态') self.click(self.efg.read_config('退货状态')) if returned is True: logging.info('选择有退货') self.element_swipe_up(30, self.efg.read_config('状态框')) self.click(self.efg.read_config('状态框确认')) elif returned is False: logging.info('选择无退货') self.element_swipe_up(60, self.efg.read_config('状态框')) self.click(self.efg.read_config('状态框确认')) if status is not None: logging.info('选择订单状态') self.click(self.efg.read_config('订单状态')) if status is True: logging.info('选择订单正常') self.element_swipe_up(30, self.efg.read_config('状态框')) self.click(self.efg.read_config('状态框确认')) elif status is False: logging.info('选择订单作废') self.element_swipe_up(60, self.efg.read_config('状态框')) self.click(self.efg.read_config('状态框确认')) else: pass logging.info(r'点击确认') self.click(self.efg.read_config('筛选确认')) # 原单账户选择 def original_order_account_selection(self, name): self.click(self.efg.read_config('退款账户')) self.click_text(name) # 原单备注填写 def original_order_remarks_edit(self, info): self.type(self.efg.read_config('备注信息'), info) # 直接退货选择销售员 def direct_return_seller_selection(self, seller_name): self.click(self.efg.read_config('选择销售员')) self.click_text(seller_name) self.click(self.efg.read_config('确认退货')) # 直接退货账户选择 def direct_return_account_selection(self, name): self.click(self.efg.read_config('直接退货退款账户')) self.click_text(name) # 直接退货备注填写 def direct_return_remarks_edit(self, info): logging.info('填写备注信息') self.type(self.efg.read_config('直接退货备注'), info) # 直接退货选择商品 def direct_return_goods_selection(self, name, num): logging.info('点击选择已有商品') self.click_text(self.efg.read_config('选择商品')) self.click_text(name) for i in range(0, num): self.click(self.efg.read_config('加减按钮')) logging.info('点击确认') self.click(self.efg.read_config('悬浮框商品确认按钮')) self.click(self.efg.read_config('确认退货')) # 选择退货商品 def choose_return_goods(self, good_num=None, good_name=None): self.click_text(good_name) for i in range(0, good_num): self.click(self.efg.read_config('加减按钮')) logging.info('点击确认') self.click(self.efg.read_config('确认退货')) # 改价 def modfiy_price_action(self, price): logging.info(r'改价操作') self.click(self.efg.read_config('改价按钮')) logging.info(r'悬浮框改价按钮') sleep(2) self.click(self.efg.read_config('改价按钮')) logging.info(r'输入修改价格') self.type(self.efg.read_config('改价输入框'), price) logging.info(r'点击改价确认') self.click(self.efg.read_config('弹框确认')) logging.info(r'确认选择商品') self.click(self.efg.read_config('悬浮框商品确认按钮')) # 确认退货 def define_salesreturn(self): logging.info(r'点击确认退货按钮') self.click(self.efg.read_config('确认退货')) # 查看详情 def enter_detail_interface(self): logging.info('进入详情界面') self.click(self.efg.read_config('查看详情')) # 获取销售成功状态 def check_sales_return_success_status(self): logging.info(r'检查交易成功状态') flag = self.is_exists(self.efg.read_config('退货成功')) return flag # 获取销售退货单号 def get_sales_return_ordernum(self): logging.info(r'获取销售退货单号') sales_return_ordernum = self.get_text(self.efg.read_config('销售退货单号')) return sales_return_ordernum def get_detail_return_ordernum(self): logging.info(r'获取销售退货单号') sales_return_ordernum = self.get_text(self.efg.read_config('详情销售退货单号')) return sales_return_ordernum # 检查结算方式 def check_account_type(self): info = self.get_text(self.efg.read_config('检查结算方式')) return info # 检查退款金额 def check_total_money(self): total = self.get_text(self.efg.read_config('退货金额')) return total # 检查备注信息 def check_remaks(self): info = self.get_text(self.efg.read_config('详情备注')) return info # 原单退货 def original_order_return_action(self, good_name=None, good_num=None, normal=False, keyword=None, account=None, remark=None, modify=None, is_continue=False): self.enter_sales_return() self.sales_order_selection() self.filter_order(keyword=keyword) self.choose_return_goods(good_name=good_name, good_num=good_num) if normal is True: self.define_salesreturn() if modify is not None: self.modfiy_price_action(modify) self.define_salesreturn() self.enter_detail_interface() if account is not None: self.original_order_account_selection(account) self.define_salesreturn() self.enter_detail_interface() if remark is not None: self.original_order_remarks_edit(remark) self.define_salesreturn() self.enter_detail_interface() if is_continue: self.click(self.efg.read_config('继续退货')) self.sales_order_selection() self.filter_order(keyword=keyword) self.choose_return_goods(good_name=good_name, good_num=good_num) if modify is not None: self.modfiy_price_action(modify) if account is not None: self.original_order_account_selection(account) if remark is not None: self.original_order_remarks_edit(remark) self.define_salesreturn() # 直接退货 def direct_return_action(self, seller_name, normal=False, name=None, num=None, account=None, modify=None, remark=None, is_continue=False): self.enter_sales_return() self.click_text('直接退货') self.direct_return_goods_selection(name, num) self.direct_return_seller_selection(seller_name=seller_name) if normal: self.define_salesreturn() if account is not None: logging.info('选择账户') self.direct_return_account_selection(account) self.define_salesreturn() if modify is not None: self.modfiy_price_action(modify) self.define_salesreturn() self.enter_detail_interface() if remark is not None: self.direct_return_remarks_edit(remark) self.define_salesreturn() self.enter_detail_interface() if is_continue: self.click(self.efg.read_config('继续退货')) self.click_text('直接退货') self.direct_return_goods_selection(name, num) self.direct_return_seller_selection(seller_name=seller_name) self.define_salesreturn()
class GoodsBusiness(BaseOperation): def __init__(self, driver): super(GoodsBusiness, self).__init__(driver) self.efg = ReadIni(file_name='goods_page.ini') # 进入商品管理界面 def enter_goods_list(self): sleep(2) logging.info('进入商品管理界面') self.click_text(self.efg.read_config('商品管理')) sleep(2) # 选择类目 def choose_category(self): logging.info('点击新增商品') self.click(self.efg.read_config('新增按钮')) logging.info('选择商品类目') self.click(self.efg.read_config('商品类目')) sleep(2) logging.info('选择男装') self.click_text(self.efg.read_config('类目选择1')) sleep(2) logging.info('选择上装') self.click_text(self.efg.read_config('类目选择2')) sleep(2) logging.info('选择男士T恤') self.click_text(self.efg.read_config('类目选择3')) sleep(2) # 新增商品操作 def type_must_field(self, goodsname, costprice, saleprice, color_value, size_value, *args): """ :param goodsname: :param costprice: :param saleprice: :param color_value: :param size_value: :param args: :return: """ self.choose_category() self.type(self.efg.read_config('商品名称'), goodsname) sleep(1) logging.info('输入成本价') self.type(self.efg.read_config('采购价格'), costprice) sleep(1) logging.info('输入零售价') self.type(self.efg.read_config('销售价格'), saleprice) sleep(1) logging.info('点击颜色') self.click_text(self.efg.read_config('颜色选择')) sleep(1) logging.info('选择颜色') self.click_text(color_value) sleep(1) logging.info('点击确认') self.click(self.efg.read_config('确认选择')) sleep(1) logging.info('点击尺码') self.click_text(self.efg.read_config('尺码选择')) sleep(1) logging.info('选择尺码') self.click_text(size_value) sleep(1) logging.info('点击确认') self.click(self.efg.read_config('确认选择')) sleep(1) if args: if len(args) == 2: logging.info('添加商品货号') self.type(self.efg.read_config('商品货号输入'), args[0]) sleep(1) logging.info('滑动到自定义分类界面') self.swipe_up(500) sleep(1) # self.swipe(self.新增商品界面, 'up', 0, -1) logging.info('输入初始库存') self.click(self.efg.read_config('初始库存输入')) sleep(1) logging.info('输入库存数') for i in range(0, args[1]): self.click(self.efg.read_config('添加库存数按钮')) sleep(1) logging.info('点击确认') self.click(self.efg.read_config('确认选择')) sleep(1) elif len(args) == 3: logging.info('添加商品货号') self.type(self.efg.read_config('商品货号输入'), args[0]) sleep(1) logging.info('滑动到自定义分类界面') self.swipe_up(500) sleep(1) # self.swipe(self.新增商品界面, 'up', 0, -1) logging.info('输入初始库存') self.click(self.efg.read_config('初始库存输入')) sleep(1) logging.info('输入库存数') for i in range(0, args[1]): self.click(self.efg.read_config('添加库存数按钮')) sleep(1) logging.info('点击确认') self.click(self.efg.read_config('确认选择')) sleep(1) logging.info('商品条码输入') self.type(self.efg.read_config('商品条码输入'), args[2]) sleep(1) elif len(args) == 4: logging.info('添加商品货号') self.type(self.efg.read_config('商品货号输入'), args[0]) sleep(1) logging.info('滑动到自定义分类界面') # self.swipe(self.efg.read_config('新增商品界面'), 'up', 0, -1) self.swipe_up(500) sleep(1) logging.info('输入初始库存') self.click(self.efg.read_config('初始库存输入')) sleep(1) logging.info('输入库存数') for i in range(0, args[1]): self.click(self.efg.read_config('添加库存数按钮')) sleep(1) logging.info('点击确认') self.click(self.efg.read_config('确认选择')) sleep(1) logging.info('商品条码输入') self.type(self.efg.read_config('商品条码输入'), args[2]) sleep(1) logging.info('输入商品备注') self.type(self.efg.read_config('商品备注'), args[3]) sleep(1) # elif len(args) == 11: # logging.info('添加商品货号') # self.type(self.efg.read_config('商品货号输入'), args[0]) # logging.info('滑动到添加库存界面') # self.swipe_up(500) # # self.swipe(self.新增商品界面, 'up', 0, -1) # logging.info('输入初始库存') # self.click(self.efg.read_config('初始库存输入')) # logging.info('输入库存数') # for i in range(0, args[1]): # self.click(self.efg.read_config('添加库存数按钮')) # logging.info('点击确认') # self.click(self.efg.read_config('确认选择')) # logging.info('商品条码输入') # self.type(self.efg.read_config('商品条码输入'), args[2]) # logging.info('输入商品备注') # self.type(self.efg.read_config('商品备注'), args[3]) # logging.info('输入库存上限') # self.type(self.efg.read_config('库存上限'), args[4]) # logging.info('输入库存下限') # self.type(self.efg.read_config('库存下限'), args[5]) # logging.info('滑动到其他参数界面') # self.swipe_up(500) # # self.swipe(self.新增商品界面, 'up', 0, -0.5) # logging.info('输入单位') # self.type_other_parameter('请输入单位信息', args[6]) # logging.info('输入成分') # self.type_other_parameter('请输入成分信息', args[7]) # logging.info('输入季节') # self.type_other_parameter('请输入季节信息', args[8]) # logging.info('输入款式') # self.type_other_parameter('请输入款式信息', args[9]) # logging.info('输入品牌') # self.type_other_parameter('请输入品牌信息', args[10]) # else: # logging.info('添加商品货号') # self.type(self.efg.read_config('商品货号输入'), args[0]) else: pass # 确认添加 def confirm_add_goods(self): logging.info('点击保存') self.click(self.efg.read_config('保存按钮')) # 获取商品货号 def get_goods_num(self): logging.info('获取商品货号') goods_num = self.get_text(self.efg.read_config('商品货号')) logging.info("商品货号:%s" % goods_num) list1 = goods_num.split(':') return list1[1] # 获取商品条码 def get_goods_barcode(self): logging.info('获取商品条码') goods_barcode = self.get_text(self.efg.read_config('商品条码')) logging.info("商品条码:%s" % goods_barcode) list1 = goods_barcode.split(':') return list1[1] # 获取其他参数 def get_other_parameter(self): other_parameters = self.get_text(self.efg.read_config('其他参数值')) return other_parameters # 获取单品货号 def get_sku_barcode(self): logging.info('获取单品货号') sku_num = self.get_text(self.efg.read_config('单品货号')) logging.info("单品货号:%s" % sku_num) return sku_num # # 获取库存信息 # def get_stock_num(self): # logging.info('点击库存信息') # tab_name = self.get_elements(self.库存信息1, self.库存信息2, self.库存信息3, self.库存信息4) # for i in range(0, len(tab_name)): # if tab_name[i].get_text() == '库存信息': # tab_name[i].click() # stock_num = self.get_text(self.详细信息库存数) # return stock_num # # # 输入其他参数 # def type_other_parameter(self, value, *args): # logging.info('输入其他参数') # tab_name = self.get_elements(self.其他参数1, self.其他参数2, self.其他参数3) # for i in range(0, len(tab_name)): # if tab_name[i].get_text() == value: # tab_name[i].set_text(args) # 查看商品详情 def get_goods_details(self): logging.info('查看商品详情') self.click(self.efg.read_config('查看商品详情')) # 继续添加商品 def go_on_add_goods(self): logging.info('继续添加商品') self.click(self.efg.read_config('继续添加商品')) # 返回首页 def go_home(self): logging.info('返回首页') self.click(self.efg.read_config('返回首页')) # 商品下架操作 def goods_obtained_action(self, name): logging.info('点击商品') self.click_text(name) logging.info('点击下架') self.click(self.efg.read_config('上下架按钮')) logging.info('点击弹框确认') self.click(self.efg.read_config('弹框确认')) # 商品上架操作 def goods_shelf_action(self, name): logging.info('点击筛选按钮') self.click(self.efg.read_config('筛选按钮')) logging.info('点击取消已上架查询') self.click(self.efg.read_config('筛选上架')) logging.info('点击选择已下架查询') self.click(self.efg.read_config('筛选下架')) logging.info('点击确认查询') self.click(self.efg.read_config('筛选确认')) logging.info('点击商品') self.click_text(name) logging.info('点击上架') self.click(self.efg.read_config('上下架按钮')) logging.info('点击确认') self.click(self.efg.read_config('弹框确认')) logging.info('点击back按钮') self.click(self.efg.read_config('回退按钮')) logging.info('点击筛选按钮') self.click(self.efg.read_config('筛选按钮')) logging.info('点击取消已下架查询') self.click(self.efg.read_config('筛选下架')) logging.info('点击选择已上架查询') self.click(self.efg.read_config('筛选上架')) logging.info('点击确认查询') self.click(self.efg.read_config('筛选确认')) # 删除操作 def goods_delete_action(self): logging.info('点击商品') self.click_text(self.efg.read_config('商品列表名称')) logging.info('点击详情页面操作按钮') self.click(self.efg.read_config('商品详情页面操作按钮')) logging.info('点击删除按钮') self.click(self.efg.read_config('删除商品')) logging.info('点击确认') self.click(self.efg.read_config('弹框确认')) # 检查新增是否成功 def check_success_status(self): status = self.get_text(self.efg.read_config('添加成功')) return status # 检查下架状态 def check_obtained_status(self): status = self.get_text(self.efg.read_config('下架状态')) return status # 列表编辑操作 def list_edit_action(self, value): logging.info('点击列表操作') self.click(self.efg.read_config('列表操作按钮')) sleep(2) logging.info('点击编辑') self.click(self.efg.read_config('列表编辑按钮')) sleep(2) logging.info('修改商品名称') self.type(self.efg.read_config('商品名称'), value) sleep(2) logging.info('点击保存') self.click(self.efg.read_config('保存按钮')) # 详情编辑操作 def details_edit_action(self, value): logging.info('点击商品详情') self.click(self.efg.read_config('商品名称')) sleep(2) logging.info('点击编辑') self.click(self.efg.read_config('详情编辑按钮')) sleep(1) logging.info('修改商品名称') self.type(self.efg.read_config('商品名称'), value) sleep(1) logging.info('点击保存') self.click(self.efg.read_config('保存按钮')) # 新增规则组 def add_rule_group(self, name, group_name): self.choose_category() logging.info('点击颜色或者尺码') self.click_text(name) logging.info('点击添加属性规则组') self.click(self.efg.read_config('属性规则组添加')) logging.info('输入规则组名称') self.type(self.efg.read_config('规则组输入框'), group_name) logging.info('点击确认') self.click(self.efg.read_config('弹框确认')) # 编辑规则组 def edit_rule_group(self, name, group_name): self.choose_category() logging.info('点击颜色或者尺码') self.click_text(name) logging.info('点击编辑规则组名称') self.click(self.efg.read_config('规则组编辑')) logging.info('输入修改后规则组名称') self.type(self.efg.read_config('规则组输入框'), group_name) logging.info('点击确认') self.click(self.efg.read_config('弹框确认')) # 编辑规则组 def delete_rule_group(self, name): self.choose_category() logging.info('点击颜色或者尺码') self.click_text(name) logging.info('点击删除按钮') self.click(self.efg.read_config('规则组删除')) logging.info('点击确认') self.click(self.efg.read_config('弹框确认')) # 新增自定义分类 def add_custom_classification(self, name): logging.info('点击新增商品') self.click(self.efg.read_config('新增按钮')) sleep(1) logging.info('滑动到自定义分类界面') self.swipe_up(500) # self.swipe(self.新增商品界面, 'up', 0, -0.8) logging.info('点击自定义分类') self.click(self.efg.read_config('自定义分类')) logging.info('点击新增') self.click(self.efg.read_config('操作按钮')) logging.info('输入自定义分类名称') self.type(self.efg.read_config('自定义分类名称'), name) logging.info('点击确认') self.click(self.efg.read_config('确认选择')) sleep(2) # # 编辑自定义分类 # def edit_custom_classification(self, name): # logging.info('点击新增商品') # self.click(self.新增按钮) # logging.info('滑动到自定义分类界面') # self.swipe(self.新增商品界面, 'up', 0, -0.8) # logging.info('点击自定义分类') # self.click(self.自定义分类) # logging.info('向左滑动已有分类') # self.swipe(self.自定义分类滑动, 'left', -0.5, 0) # logging.info('点击编辑') # self.click(self.自定义类目编辑) # logging.info('输入自定义分类名称') # self.type(self.自定义分类名称, name) # logging.info('点击确认') # self.click(self.确认选择) # # 删除自定义分类 # def delete_custom_classification(self): # logging.info('点击新增商品') # self.click(self.新增按钮) # logging.info('滑动到自定义分类界面') # self.swipe(self.新增商品界面, 'up', 0, -0.8) # logging.info('点击自定义分类') # self.click(self.自定义分类) # logging.info('向左滑动已有分类') # self.swipe(self.自定义分类滑动, 'left', -0.5, 0) # logging.info('点击删除') # self.click(self.自定义类目删除) # # 规则属性新增 # def add_rule_attribute(self, name, prop_name): # self.choose_category() # logging.info('点击尺码或者颜色') # self.click_text(name) # logging.info('点击新增属性') # self.click(self.efg.read_config('规则属性新增')) # logging.info('输入新增属性名称') # self.type(self.efg.read_config('属性输入框'), prop_name) # logging.info('点击保存') # self.click(self.efg.read_config('确认选择')) # # # 判断长按的属性 # def long_cilck_prop(self, value): # array_list = self.get_elements(self.属性值组, self.属性值获取) # for i in range(0, len(array_list)): # if array_list[i].get_text() == value: # array_list[i].long_click() # # # 选择属性规则 # def choose_prop(self, value): # array_list = self.get_elements(self.属性值组, self.属性值获取) # for i in range(0, len(array_list)): # if array_list[i].get_text() == value: # array_list[i].click() # # # 判断属性编辑或删除 # def edit_delete_prop(self, value): # array_list = self.get_elements(self.属性值编辑删除, self.属性值编辑删除2) # for i in range(0, len(array_list)): # if array_list[i].get_text() == value: # array_list[i].click() # # # 规则属性编辑 # def edit_rule_attribute(self, name, prop_name, new_prop_name): # self.choose_category() # logging.info('点击尺码或者颜色') # self.click_text(name) # logging.info('点击需要编辑的属性值') # self.long_cilck_prop(prop_name) # logging.info('点击编辑') # self.edit_delete_prop('编辑') # logging.info('编辑属性名称') # self.type(self.属性输入框, new_prop_name) # logging.info('点击保存') # self.click(self.确认选择) # # # 规则属性删除 # def delete_rule_attribute(self, name, prop_name): # self.choose_category() # logging.info('点击尺码或者颜色') # self.click_text(name) # logging.info('点击需要编辑的属性值') # self.long_cilck_prop(prop_name) # logging.info('点击删除') # self.edit_delete_prop('删除') # logging.info('点击确认') # self.click(self.弹框确认) # # # 搜索规则属性 # def search_prop(self, prop_name, porp_value): # self.choose_category() # logging.info('点击尺码或者颜色') # self.click_text(prop_name) # logging.info('输入查询的属性值') # self.click(self.搜索框) # text(porp_value) # time.sleep(3) # dev = device() # dev.yosemite_ime.code("3") # # # 搜索颜色属性 # def search_color_prop(self, porp_value): # self.search_prop(self.颜色选择, porp_value) # # # 新增颜色属性 # def add_color_prop(self, prop_name): # self.add_rule_attribute(self.颜色选择, prop_name) # # # 新增尺码属性 # def add_size_prop(self, prop_name): # self.add_rule_attribute(self.尺码选择, prop_name) # # # 编辑颜色属性 # def edit_color_prop(self, prop_name, new_prop_name): # self.edit_rule_attribute(self.颜色选择, prop_name, new_prop_name) # # # 编辑尺码属性 # def edit_size_prop(self, prop_name, new_prop_name): # self.edit_rule_attribute(self.尺码选择, prop_name, new_prop_name) # # # 删除颜色属性 # def delete_color_prop(self, prop_name): # self.delete_rule_attribute(self.颜色选择, prop_name) # # # 删除尺码属性 # def delete_size_prop(self, prop_name): # self.delete_rule_attribute(self.尺码选择, prop_name) # # # 新增颜色规则组 # def add_color_rule_group(self, group_name): # self.add_rule_group(self.颜色选择, group_name) # # # 新增尺码规则组 # def add_size_rule_group(self, group_name): # self.add_rule_group(self.尺码选择, group_name) # # # 编辑颜色规则组 # def edit_color_rule_group(self, group_name): # self.edit_rule_group(self.颜色选择, group_name) # # # 编辑颜色规则组 # def edit_size_rule_group(self, group_name): # self.edit_rule_group(self.尺码选择, group_name) # # # 删除颜色规则组 # def delete_color_rule_group(self): # self.delete_rule_group(self.颜色选择) # # # 删除尺码规则组 # def delete_size_rule_group(self): # self.delete_rule_group(self.尺码选择) def check_shelf_status(self, name): flag = self.find_element_text(name) if flag: return True else: return False def check_goods_is_not_exist(self, name): flag = self.find_element_text(name) if flag: return False else: return True def get_goods_names(self): text = self.find_element(self.efg.read_config('商品名称')).text return text def check_classification_is_exist(self, value): flag = self.find_element_text(value) if flag: return True else: return False
class PurchaseOrderBusiness(BaseOperation): def __init__(self, driver): super(PurchaseOrderBusiness, self).__init__(driver) self.efg = ReadIni(file_name='purchaseorder_page.ini') def purchaseorder_action(self, keyword=None, settlement=None, supplier_name=None, returned=None, status=None, obsolete=False, copy=False, copy_supplier_name=None, modify=False, price=None, is_return=False): self.enter_puchaseorder_interface() self.filter_order(keyword=keyword, settlement=settlement, supplier_name=supplier_name, returned=returned, status=status) self.enter_order_detail() self.operating_document_action(obsolete=obsolete, copy=copy, keyword=keyword, copy_supplier_name=copy_supplier_name) self.purchase_order_return(is_return=is_return, modify=modify, price=price) # 进入采购单界面 def enter_puchaseorder_interface(self): logging.info(r'进入库存模块') self.click(self.efg.read_config('库存按钮')) logging.info(r'进入采购单界面') self.click_text(self.efg.read_config('采购单界面')) # 单据筛选 def filter_order(self, keyword=None, settlement=None, supplier_name=None, returned=None, status=None): logging.info(r'点击筛选按钮') self.click(self.efg.read_config('采购单列表筛选按钮')) if keyword is not None: logging.info(r'输入单号') self.type(self.efg.read_config('关键字输入框'), keyword) if settlement is not None: logging.info('结算方式') self.click(self.efg.read_config('选择结算方式')) self.click_text(settlement) if supplier_name is not None: logging.info('选择供应商') self.click(self.efg.read_config('选择供应商')) self.click_text(supplier_name) if returned is not None: logging.info('选择退货状态') self.click(self.efg.read_config('有无退货')) if returned is True: logging.info('选择有退货') self.element_swipe_up(30, self.efg.read_config('状态滑动框')) self.click(self.efg.read_config('滑动框确认')) elif returned is False: logging.info('选择无退货') self.element_swipe_up(60, self.efg.read_config('状态滑动框')) self.click(self.efg.read_config('滑动框确认')) if status is not None: logging.info('选择订单状态') self.click(self.efg.read_config('状态选择')) if status is True: logging.info('选择订单正常') self.element_swipe_up(30, self.efg.read_config('状态滑动框')) self.click(self.efg.read_config('滑动框确认')) elif status is False: logging.info('选择订单作废') self.element_swipe_up(60, self.efg.read_config('状态滑动框')) self.click(self.efg.read_config('滑动框确认')) else: pass logging.info(r'点击确认') self.click(self.efg.read_config('筛选界面确认按钮')) # 进入单据详情 def enter_order_detail(self): logging.info('进入订单详情') self.click(self.efg.read_config('采购单列表商品名称')) # 对单据进行操作 def operating_document_action(self, obsolete=False, copy=False, keyword=None, copy_supplier_name=None): if obsolete is True: logging.info(r'作废单据') self.click(self.efg.read_config('采购单详情操作按钮')) logging.info(r'点击作废') self.click(self.efg.read_config('作废订单')) logging.info(r'点击确认') self.click(self.efg.read_config('弹框确认按钮')) sleep(2) logging.info(r'点击后退按钮') self.click(self.efg.read_config('回退按钮')) logging.info(r'') self.click(self.efg.read_config('采购单列表筛选按钮')) logging.info(r'输入单号') self.type(self.efg.read_config('关键字输入框'), keyword) logging.info('选择订单状态') self.click(self.efg.read_config('状态选择')) logging.info('选择订单作废') self.element_swipe_up(60, self.efg.read_config('状态滑动框')) self.click(self.efg.read_config('滑动框确认')) logging.info('点击筛选确认') self.click(self.efg.read_config('筛选界面确认按钮')) sleep(2) if copy is True: logging.info(r'复制订单') self.click(self.efg.read_config('采购单详情操作按钮')) logging.info(r'点击复制订单') self.click(self.efg.read_config('复制订单')) logging.info(r'点击确认') self.click(self.efg.read_config('弹框确认按钮')) self.copy_follow_operation(copy_supplier_name=copy_supplier_name) # 复制后续操作 def copy_follow_operation(self, copy_supplier_name=None): logging.info(r'进入供应商选择界面') self.click(self.efg.read_config('供应商选择')) sleep(1) logging.info(r'选择供应商') self.click_text(copy_supplier_name) logging.info(r'确认入库') self.click(self.efg.read_config('退货确认')) # 退货 def purchase_order_return(self, is_return=False, modify=False, price=None): if is_return: logging.info('点击退货按钮') self.click(self.efg.read_config('采购单详情退货按钮')) if modify is True: logging.info('点击改价按钮') self.click(self.efg.read_config('改价')) logging.info('输入修改后价格') self.type(self.efg.read_config('改价输入'), price) self.click(self.efg.read_config('弹框确认按钮')) logging.info('点击添加商品') self.click(self.efg.read_config('加按钮')) self.click(self.efg.read_config('退货确认')) sleep(2) self.click(self.efg.read_config('退货确认')) def get_purchaseorder_return_information(self): flag = self.is_exists(self.efg.read_config('采购退货成功')) purchasereturn_ordernum = self.get_text( self.efg.read_config('采购退货单单号')) purchase_ordernum = self.get_text(self.efg.read_config('原始采购单单号')) return_num = self.get_text(self.efg.read_config('退货数量'))[0] return_money = self.get_text(self.efg.read_config('退款金额')) settlement_type = self.get_text(self.efg.read_config('结算方式')) supplier_name = self.get_text(self.efg.read_config('采购单列表供应商名称')) return_dict = { "status": flag, "purchasereturn_ordernum": purchasereturn_ordernum, "purchase_ordernum": purchase_ordernum, "return_num": return_num, "return_money": return_money, "settlement_type": settlement_type, "supplier_name": supplier_name } return return_dict # 采购单详情采购单单号 def get_detail_purchase_order(self): order_num = self.get_text(self.efg.read_config('采购单详情中采购单号')) return order_num # 采购单详情结算方式 def get_detail_purchase_settlementtype(self): settlementtyp = self.get_text(self.efg.read_config('结算方式')) return settlementtyp # 采购单详情备注信息 def get_detail_purchase_remark(self): remark = self.get_text(self.efg.read_config('详情备注')) return remark def get_detail_purchase_supplier(self): supplier = self.get_text(self.efg.read_config('详情供应商')) return supplier # 检查作废是否成功 def check_obsolete_status(self): logging.info(r'检查成功状态') flag = self.is_exists(self.efg.read_config('采购单列表商品名称')) return flag # 获取采购成功状态 def check_transaction_success_status(self): logging.info(r'检查交易成功状态') flag = self.is_exists(self.efg.read_config('采购退货成功')) return flag
class RegisterBusiness(BaseOperation): def __init__(self, driver): super(RegisterBusiness, self).__init__(driver) self.efg = ReadIni(file_name='register_page.ini') # 随机数 number = random.randint(0, 9999999) def register_action(self, register_username, register_code, register_password): logging.info('进入注册页面') self.click(self.efg.read_config("注册按钮")) sleep(5) logging.info('输入注册手机号: %s' % register_username) self.type(self.efg.read_config("注册用户名输入框"), register_username) logging.info('输入注册时验证码: %s' % register_code) self.type(self.efg.read_config("验证码输入框"), register_code) logging.info('输入注册时的密码: %s' % register_password) self.type(self.efg.read_config("密码输入框"), register_password) logging.info('点击下一步') self.click(self.efg.read_config("下一步按钮")) sleep(2) logging.info('选择商家') self.click(self.efg.read_config("商家按钮")) logging.info('点击下一步') self.click(self.efg.read_config("下一步按钮")) sleep(2) logging.info('输入公司名称') self.type(self.efg.read_config("公司名称输入框"), '自动化测试公司' + str(self.number)) logging.info('输入门店名称') self.type(self.efg.read_config("门店输入框"), '自动化测试门店' + str(self.number)) logging.info('输入省市县地址') self.click(self.efg.read_config("城市选择框")) logging.info('点击确认,默认选择第一个城市') self.click(self.efg.read_config("城市确认按钮")) logging.info('输入详细地址') self.type(self.efg.read_config("详细地址"), r'李洲全详细地址' + str(self.number)) logging.info('点击下一步') self.click(self.efg.read_config("下一步按钮")) sleep(2) logging.info('点击跳过引导按钮') self.click(self.efg.read_config("跳过按钮")) sleep(2) def register_common_action(self, register_username, register_code, register_password): logging.info('进入注册页面') self.click(self.efg.read_config("注册按钮")) sleep(2) logging.info('输入注册手机号: %s' % register_username) self.type(self.efg.read_config("注册用户名输入框"), register_username) logging.info('输入注册时验证码: %s' % register_code) self.type(self.efg.read_config("验证码输入框"), register_code) logging.info('输入注册时的密码: %s' % register_password) self.type(self.efg.read_config("密码输入框"), register_password) logging.info('点击下一步') self.click(self.efg.read_config("下一步按钮")) sleep(2) def check_register_success_status(self): logging.info('==检查注册后登录状态==') flag = self.is_exists(self.efg.read_config("今日销售额")) return flag def check_register_fail_status(self): logging.info(r'检查状态开始') flag = self.is_exists(self.efg.read_config("下一步按钮")) return flag
import smtplib import os import mimetypes import time import sys import logging sys.path.append('./..') from email.mime.text import MIMEText from email.mime.multipart import MIMEMultipart from email.mime.image import MIMEImage from base.BaseReadIni import ReadIni from util import operationFile cfg = ReadIni(isconfig=True, file_name="email_conf.ini") email_host = cfg.read_config('email_config', 'email_host') send_user = cfg.read_config('email_config', 'send_user') password = cfg.read_config('email_config', 'password') def pre_send_mail(report_name): """发送邮件预处理""" logging.info('测试任务完成,编写邮件中...') message = MIMEMultipart("related") current_time = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(time.time())) to_addr = cfg.read_config("email", "To_addr") cc_addr = cfg.read_config("email", "Cc_addr") user_list = to_addr.split(',') + cc_addr.split(',') sub = "【自动发送】移动端APP自动化测试报告" + current_time user = send_user
class SalesOrderBusiness(BaseOperation): def __init__(self, driver): super(SalesOrderBusiness, self).__init__(driver) self.efg = ReadIni(file_name='salesorder_page.ini') # 进入销售单界面 def enter_sales_order_action(self): logging.info(r'点击库存按钮') self.click(self.efg.read_config('库存按钮')) logging.info(r'点击进入销售单界面') self.click_text(self.efg.read_config('销售单按钮')) # 进入销售单详情 def enter_sales_order_detail(self): logging.info('进入销售单详情') self.click(self.efg.read_config('商品列表名称')) # 单据筛选 def filter_order(self, keyword=None, settlement=None, seller_name=None, cashier_name=None, returned=None, status=None): logging.info(r'点击筛选按钮') self.click(self.efg.read_config('筛选按钮')) if keyword is not None: logging.info(r'输入单号') self.type(self.efg.read_config('关键字'), keyword) if settlement is not None: logging.info('结算方式') self.click(self.efg.read_config('结算方式选择')) self.click_text(settlement) if seller_name is not None: logging.info('选择销售员') self.click(self.efg.read_config('销售员选择')) self.click_text(seller_name) if cashier_name is not None: logging.info('选择收银员') self.click(self.efg.read_config('收营员选择')) self.click_text(cashier_name) if returned is not None: logging.info('选择退货状态') self.click(self.efg.read_config('有无退货选择')) if returned is True: logging.info('选择有退货') self.element_swipe_up(30, self.efg.read_config('状态框')) self.click(self.efg.read_config('状态框确认')) elif returned is False: logging.info('选择无退货') self.element_swipe_up(60, self.efg.read_config('状态框')) self.click(self.efg.read_config('状态框确认')) if status is not None: self.swipe_up(2000) logging.info('选择订单状态') self.click(self.efg.read_config('状态选择')) if status is True: logging.info('选择订单正常') self.element_swipe_up(30, self.efg.read_config('状态框')) self.click(self.efg.read_config('状态框确认')) elif status is False: logging.info('选择订单作废') self.element_swipe_up(60, self.efg.read_config('状态框')) self.click(self.efg.read_config('状态框确认')) else: pass logging.info(r'点击确认') self.click(self.efg.read_config('筛选确认按钮')) self.enter_sales_order_detail() # 结账action def pay_bill_action(self): logging.info(r'去结账') self.click(self.efg.read_config('结账')) logging.info(r'现金支付') self.click_text(self.efg.read_config('收款类型')) logging.info('确认收银') self.click(self.efg.read_config('确认收款')) # 对单据进行操作 def operating_document_action(self, obsolete=False, copy=False, keyword=None): if obsolete is True: logging.info(r'作废单据') self.click(self.efg.read_config('销售单详情操作按钮')) logging.info(r'点击作废') self.click(self.efg.read_config('作废按钮')) logging.info(r'点击确认') self.click(self.efg.read_config('弹框确认')) logging.info(r'点击回退') self.click(self.efg.read_config('回退按钮')) logging.info(r'点击筛选') self.filter_order(keyword=keyword, status=False) self.click(self.efg.read_config('回退按钮')) if copy is True: logging.info(r'复制订单') self.click(self.efg.read_config('销售单详情操作按钮')) logging.info(r'点击复制订单') self.click(self.efg.read_config('复制按钮')) logging.info(r'点击确认') self.click(self.efg.read_config('弹框确认')) self.pay_bill_action() # 退货 def sales_order_return(self, modify=False, price=None): logging.info('点击退货按钮') self.click(self.efg.read_config('销售单退货按钮')) if modify is True: logging.info('点击改价按钮') self.click(self.efg.read_config('改价')) logging.info('输入修改后价格') self.type(self.efg.read_config('改价输入框'), price) self.click(self.efg.read_config('弹框确认')) logging.info('点击添加商品') self.click(self.efg.read_config('加按钮')) self.click(self.efg.read_config('确认退货')) self.click(self.efg.read_config('确认退货')) # 检查交易成功状态 def check_transaction_success_status(self): logging.info(r'检查交易成功状态') text = self.get_text(self.efg.read_config('交易状态')) if text == r'交易成功': return True # 获取退款总金额 def check_return_total_money(self): money = self.get_text(self.efg.read_config('退款金额')) return money # 获取交易价格 def get_order_price(self): logging.info(r'获取订单金额') price = self.get_text(self.efg.read_config('实际收款金额')) return price # 获取销售单号 def get_sales_order_num(self): logging.info(r'获取单号') sales_order_num = self.get_text(self.efg.read_config('销售单单号')) return sales_order_num # 获取销售退货单单号 def get_sales_return_order_num(self): logging.info(r'获取单号') sales_return_order_num = self.get_text(self.efg.read_config('销售退货单单号')) return sales_return_order_num # 判断单据是否作废 def check_sales_order_status(self): flag = self.is_exists(self.efg.read_config('商品列表名称')) return flag # 销售单测试用例 def sales_order_action(self, keyword=None, settlement=None, seller_name=None, cashier_name=None, returned=None, status=None, obsolete=False, copy=False, modify=False, price=None, sales_return=False): self.enter_sales_order_action() self.filter_order(keyword=keyword, settlement=settlement, seller_name=seller_name, cashier_name=cashier_name, returned=returned, status=status) if copy or obsolete: self.operating_document_action(obsolete=obsolete, copy=copy, keyword=keyword) if sales_return: self.sales_order_return(modify=modify, price=price)
class PurchaseBusiness(BaseOperation): def __init__(self, driver): super(PurchaseBusiness, self).__init__(driver) self.efg = ReadIni(file_name='purchase_page.ini') def pruchase_action(self, goodname1=None, goodname2=None, goodnum=None, supplier_name=None, price=None, settlement=None, remark=None): """ goodname: 商品名称 goodnum: 采购商品数量 price: 采购商品改价,修改价格 supplier_name: 供应商名称 settlement: 结算账号类型 remark: 备注信息 :return: """ self.enter_purchase_interface() self.choose_goods_action(name1=goodname1, name2=goodname2, num=goodnum) self.modfiy_price_action(price=price) self.choose_supplier(supplier_name=supplier_name) self.choose_settlement_type(settlement=settlement) self.edit_remarks(remark=remark) self.define_storage_action() # 进入采购界面 def enter_purchase_interface(self): logging.info(r'进入库存模块') self.click(self.efg.read_config('库存按钮')) logging.info(r'进入采购进货界面') self.click_text(self.efg.read_config('采购进货')) sleep(2) # 采购选购商品 def choose_goods_action(self, name1=None, name2=None, num=None): if name1 is not None: logging.info(r'点击选择已有商品') self.click_text(self.efg.read_config('选择已有商品')) logging.info(r'选择商品') self.click_text(name1) logging.info(r'添加商品数量') for i in range(0, num): self.click(self.efg.read_config('加减按钮')) logging.info(r'确认选择商品') self.click(self.efg.read_config('商品确认按钮')) if name2 is not None: self.click_text(name2) logging.info(r'添加商品数量') logging.info(r'添加商品数量') for i in range(0, num): self.click(self.efg.read_config('加减按钮')) logging.info(r'确认选择商品') self.click(self.efg.read_config('商品确认按钮')) sleep(2) logging.info(r'商品列表界面确认') self.click(self.efg.read_config('确认按钮')) sleep(2) # 选择供应商 def choose_supplier(self, supplier_name=None): logging.info(r'进入供应商选择界面') self.click(self.efg.read_config('供应商选择')) logging.info(r'选择供应商') self.click_text(supplier_name) sleep(3) # 选择结算账号 def choose_settlement_type(self, settlement=None): if settlement is not None: logging.info('进入选择结算账户界面') self.click(self.efg.read_config('结算账号选择')) logging.info('选择结算账号') self.click_text(settlement) sleep(1) # 确认入库 def define_storage_action(self): logging.info(r'确认入库') self.click(self.efg.read_config('确认按钮')) sleep(3) # 改价 def modfiy_price_action(self, price=None): if price is not None: logging.info(r'改价操作') self.click(self.efg.read_config('采购改价')) sleep(3) logging.info(r'悬浮框改价按钮') self.click(self.efg.read_config('采购改价')) sleep(3) logging.info(r'输入修改价格') self.type(self.efg.read_config('悬浮框价格输入框'), price) logging.info(r'点击改价确认') self.click(self.efg.read_config('悬浮框确认')) sleep(3) logging.info(r'确认选择商品') self.click(self.efg.read_config('商品确认按钮')) sleep(3) else: pass # 填写备注 def edit_remarks(self, remark=None): if remark is not None: logging.info('添加备注信息') self.type(self.efg.read_config('备注'), remark) sleep(3) else: pass # 新建供应商 def add_supplier(self, name): self.enter_purchase_interface() logging.info('点击进入供应商界面') self.click(self.efg.read_config('供应商选择')) logging.info('点击新增按钮') self.click(self.efg.read_config('供应商新增')) sleep(2) logging.info('输入供应商名称') self.type(self.efg.read_config('供应商编辑输入框'), name) logging.info('点击确认') self.click(self.efg.read_config('悬浮框确认')) sleep(2) # 获取信息 def get_purchase_information(self): flag = self.is_exists(self.efg.read_config('交易状态')) purchase_order_num = self.get_text(self.efg.read_config('采购单单号')) price = self.get_text(self.efg.read_config('订单总金额')) num = self.get_text(self.efg.read_config('采购数')) supplier_name = self.get_text(self.efg.read_config('供应商名称')) information_dict = {"status": flag, "purchase_order_num": purchase_order_num, "price": price, "num": num, "supplier_name": supplier_name} return information_dict
class LoginBusiness(BaseOperation): def __init__(self, driver): super(LoginBusiness, self).__init__(driver) self.efg = ReadIni(file_name='login_page.ini') # 登录成功 def login_action(self, username, password): sleep(8) logging.info(r'==登录操作开始==') logging.info('输入用户名:%s' % username) self.type(self.efg.read_config('用户名输入框'), username) logging.info('输入密码:%s' % password) self.type(self.efg.read_config('密码输入框'), password) logging.info('点击登录按钮') self.click(self.efg.read_config('登录按钮')) logging.info('登录完成') sleep(2) # 验证码登录 def login_code_action(self, username, code): sleep(8) logging.info('==验证码登录用例开始==') self.click(self.efg.read_config("验证码登录")) sleep(1) logging.info('输入用户名:%s' % username) self.type(self.efg.read_config("用户名输入框"), username) logging.info('输入验证码:%s' % code) self.type(self.efg.read_config("验证码输入框"), code) logging.info('点击登录按钮') self.click(self.efg.read_config("登录按钮")) sleep(1) # 体验账号登录 def login_experience_account_action(self): logging.info('==体验账号登录==') self.click(self.efg.read_config("体验按钮")) sleep(2) logging.info(r'体验账号登录状态验证开始') # 检查登录成功状态 def check_login_success_status(self): logging.info('==检查登录成功状态==') flag = self.is_exists(self.efg.read_config('今日销售额')) logging.info(flag) if flag: logging.info('验证状态成功!用例成功!') return True else: return False # 检查登录失败状态 def check_login_fail_status(self): logging.info('==检查登录失败状态') flag = self.is_exists(self.efg.read_config("登录按钮")) logging.info(flag) if flag: logging.info('验证状态成功!用例成功!') return True else: return False def check_toast_text(self, text): flag = self.is_toast_exist(text) return flag
class PurchaseReturnOrderBusiness(BaseOperation): def __init__(self, driver): super(PurchaseReturnOrderBusiness, self).__init__(driver) self.efg = ReadIni(file_name='purchasereturnorder_page.ini') # 进入采购单界面 def enter_puchas_return_eorder_interface(self): logging.info(r'进入库存模块') self.click(self.efg.read_config('库存按钮')) sleep(2) logging.info(r'进入采购退货单界面') self.click_text(self.efg.read_config('采购退货单界面')) sleep(2) # 单据筛选 def filter_order(self, keyword=None, settlement=None, supplier_name=None, status=None): logging.info(r'点击筛选按钮') self.click(self.efg.read_config('筛选按钮')) if keyword is not None: logging.info(r'输入单号') self.type(self.efg.read_config('关键字输入框'), keyword) if settlement is not None: logging.info('输入开始时间') self.click(self.efg.read_config('选择结算方式')) self.click_text(settlement) if supplier_name is not None: logging.info('选择供应商') self.click(self.efg.read_config('选择供应商')) self.click_text(supplier_name) if status is not None: logging.info('选择订单状态') self.click(self.efg.read_config('选择状态栏')) if status is True: logging.info('选择订单正常') self.element_swipe_up(30, self.efg.read_config('状态框')) self.click(self.efg.read_config('状态框确认')) elif status is False: logging.info('选择订单作废') self.element_swipe_up(60, self.efg.read_config('状态框')) self.click(self.efg.read_config('状态框确认')) else: pass logging.info(r'点击确认') self.click(self.efg.read_config('筛选界面确认按钮')) # 进入单据详情 def enter_order_detail(self): logging.info('进入订单详情') self.click(self.efg.read_config('采购退货单列表商品名称')) sleep(2) # 对单据进行操作 def operating_document_action(self, keyword=None, obsolete=False, copy=False): self.enter_order_detail() sleep(2) if obsolete is True: logging.info(r'作废单据') self.click(self.efg.read_config('采购退货单详情操作按钮')) logging.info(r'点击作废') self.click(self.efg.read_config('作废订单')) logging.info(r'点击确认') self.click(self.efg.read_config('弹框确认按钮')) sleep(2) logging.info(r'点击后退按钮') self.click(self.efg.read_config('回退按钮')) logging.info(r'') self.click(self.efg.read_config('筛选按钮')) logging.info(r'输入单号') self.type(self.efg.read_config('关键字输入框'), keyword) logging.info('选择订单状态') self.click(self.efg.read_config('选择状态栏')) logging.info('选择订单作废') self.element_swipe_up(60, self.efg.read_config('状态框')) self.click(self.efg.read_config('状态框确认')) logging.info('点击筛选确认') self.click(self.efg.read_config('筛选界面确认按钮')) if copy is True: logging.info(r'复制订单') self.click(self.efg.read_config('采购退货单详情操作按钮')) logging.info(r'点击复制订单') self.click(self.efg.read_config('复制订单')) logging.info(r'点击确认') self.click(self.efg.read_config('弹框确认按钮')) sleep(2) # 复制后续操作 def copy_follow_operation(self, name, is_original=False): if is_original is False: logging.info(r'进入供应商选择界面') self.click(self.efg.read_config('选择供应商')) logging.info(r'选择供应商') self.click_text(name) logging.info(r'确认入库') self.click(self.efg.read_config('确认退货')) else: logging.info(r'确认入库') self.click(self.efg.read_config('确认退货')) # 获取采购退货成功状态 def check_purchase_return_status(self): flag = self.is_exists(self.efg.read_config('采购退货成功')) return flag # 获取采购单退货生成的采购退货单单号 def get_purchase_return_order_num(self): order_num = self.get_text(self.efg.read_config('采购退货单详情中采购退货单号')) return order_num # 采购退货单详情采购单单号 def get_detail_ptuchase_order(self): order_num = self.get_text(self.efg.read_config('采购退货单详情中采购退货单号')) return order_num def get_detail_settlement_type(self): settlement = self.get_text(self.efg.read_config('采购退货单详情结算方式')) return settlement # 获取采购成功状态 def check_transaction_success_status(self): logging.info(r'检查交易成功状态') flag = self.is_exists(self.efg.read_config('采购退货成功')) return flag # 检查作废是否成功 def check_obsolete_status_(self): logging.info(r'检查成功状态') flag = self.is_exists(self.efg.read_config('采购退货单列表商品名称')) return flag # 采购退货单操作 def purchase_return_order_action(self, keyword=None, settlement=None, supplier_name=None, status=None, copy=False, obsolete=False, is_original=False): self.enter_puchas_return_eorder_interface() self.filter_order(keyword=keyword, settlement=settlement, supplier_name=supplier_name, status=status) self.enter_order_detail() self.operating_document_action(copy=copy, obsolete=obsolete, keyword=keyword) if copy: self.copy_follow_operation(supplier_name, is_original=is_original)