def test_check_inventory(): base.wait_element(base.find_xpath("显示0库存", "是")) time.sleep(1) base.wait_element_click(base.find_xpath("显示0库存", "是")) base.wait_table_refresh(base.find_xpath("组合查询"), 1, "货号") sku_code = base.wait_element(base.get_cell_xpath(1, "商家编码")).text base.wait_element_click(base.get_cell_xpath(1, "商家编码")) base.click_space() base.wait_element_click(base.find_xpath("盘点选中商品库存")) base.change_frame("库存查询框架", "新增盘点单") base.wait_element(base.get_old_cell_input_xpath( 1, "实际数量")).send_keys(Keys.CONTROL + 'a') base.wait_element(base.get_old_cell_input_xpath(1, "实际数量")).send_keys(100) base.change_frame("库存查询框架") base.wait_element_click(base.find_xpath("新增盘点单", "提交并盘点")) base.wait_element(base.find_xpath("显示0库存", "全部")) time.sleep(1) base.wait_element_click(base.find_xpath("显示0库存", "全部")) base.wait_element( base.find_xpath_by_placeholder("商家编码")).send_keys(Keys.CONTROL + 'a') base.wait_element( base.find_xpath_by_placeholder("商家编码")).send_keys(sku_code) base.wait_table_refresh(base.find_xpath("组合查询"), 1, "货号") inventory = base.wait_element( base.get_cell_xpath(sku_code, ["库存预警值", "库存数"])).text assert inventory == '100'
def test_warning_inventory(): base.wait_element(base.find_xpath("显示0库存", "是")) time.sleep(1) base.wait_element_click(base.find_xpath("显示0库存", "是")) base.wait_table_refresh(base.find_xpath("组合查询"), 1, "货号") sku_code = base.wait_element(base.get_cell_xpath(1, "商家编码")).text base.wait_element_click(base.get_cell_xpath(1, "商家编码")) base.click_space() base.wait_element_click(base.find_xpath("盘点选中商品库存")) base.change_frame("库存查询框架", "新增盘点单") base.wait_element(base.get_old_cell_input_xpath( 1, "实际数量")).send_keys(Keys.CONTROL + 'a') base.wait_element(base.get_old_cell_input_xpath(1, "实际数量")).send_keys(100) base.change_frame("库存查询框架") base.wait_element_click(base.find_xpath("新增盘点单", "提交并盘点")) base.wait_element(base.find_xpath("显示0库存", "全部")) time.sleep(1) base.wait_element_click(base.find_xpath("显示0库存", "全部")) base.wait_element( base.find_xpath_by_placeholder("商家编码")).send_keys(Keys.CONTROL + 'a') base.wait_element( base.find_xpath_by_placeholder("商家编码")).send_keys(sku_code) base.wait_table_refresh(base.find_xpath("组合查询"), 1, "货号") base.wait_element_click(base.get_cell_xpath(sku_code, "库存预警值")).send_keys(200) base.wait_element_click(base.find_xpath("库存告警", "是")) time.sleep(1) base.wait_table_refresh(base.find_xpath("组合查询"), 1, "货号") result_num = base.wait_element(base.find_xpath("已选择", "本页共")).text assert result_num == "本页共1条数据" base.wait_element_click(base.find_xpath("库存告警", "否")) base.wait_table_refresh(base.find_xpath("组合查询"), 1, "货号") result_num = base.wait_element(base.find_xpath("已选择", "本页共")).text assert result_num == "本页共0条数据"
def test_manual_split_order():# TODO:(RUI) 有BUG:全部订单页面,手工拆弹功能,拆包配货页面需要切换新表格组件,图片有问题,没做处理,当前重量字段应该是剩余可拆分数*商品重量,但是目前失效 vip_name = "会员" + base.get_now_string() vip_interface.new_vip(vip_name) print(f"{vip_name}") product_code = base.get_now_string() product_interface.new_product(product_code) sku_code = product_interface.get_sku_code(product_code)[0] product_interface.modify_sku_price(sku_code, "100") sku_info = [{'商家编码': sku_code, '数量': '2'}, ] order_code = order_interface.new_order(vip_name, sku_info)["Code"] base.fuzzy_search("订单编码", vip_name) base.wait_element_click(base.get_cell_xpath(1, "订单编码")) base.click_space() element = base.wait_element(base.get_cell_xpath(1, "订单状态")) text = element.text base.wait_element_click(base.find_xpath("拆单")) base.wait_element(base.find_xpath("拆单", "手工拆单")) time.sleep(1) base.wait_element_click(base.find_xpath("拆单", "手工拆单")) base.change_frame("全部订单框架", "拆包配货") base.wait_element(base.get_old_cell_input_xpath(1, "拆分数量")).send_keys(Keys.CONTROL+'a') base.wait_element(base.get_old_cell_input_xpath(1, "拆分数量")).send_keys("1") base.wait_element(base.find_xpath("立即拆分")) time.sleep(1) base.wait_element_click(base.find_xpath("立即拆分")) base.wait_element(base.find_xpath("提示", "请确认需要拆分出来1个商品?")) time.sleep(1) base.wait_element_click(base.find_xpath("提示", "确定")) base.change_frame("全部订单框架") base.wait_element_refresh(element, text) result = base.wait_element(base.get_cell_xpath(order_code, "订单状态")).text assert result == "部分审核" base.wait_element_click(base.get_cell_xpath(order_code, "商品信息")) other_info = order.get_float_sku_info_text(sku_code, "其他信息") assert "已审1件" in other_info
def modify_warehouse_and_express(keyword, modify_info): """ keyword:关键字,比如 order_code modify_info: {"仓库": "主仓库", "快递": "EMS",} """ with base.wait_refresh(base.get_cell_xpath(keyword, "仓库")) as e: base.wait_element_click(base.find_xpath("修改&标记")) base.wait_element_click(base.find_xpath("修改&标记", "修改仓库、快递")) base.change_frame("全部订单框架", "修改仓库和快递") for k, v in modify_info.items(): base.wait_element_click(base.find_xpath_by_tag_name(k, "input")) base.wait_element_click(base.find_xpath(v)) base.change_frame("全部订单框架") base.wait_element_click(base.find_xpath("修改仓库和快递", "确认"))
def test_multi_approve_button(): base.wait_element(base.find_xpath("订单状态", "待审核(无备注)")) time.sleep(1) base.wait_element_click(base.find_xpath("订单状态", "待审核(无备注)")) base.wait_table_refresh(base.find_xpath("组合查询"), 1, "订单编码") order_code = base.wait_element(base.get_cell_xpath(1, "订单编码")).text base.wait_element(base.find_xpath_by_placeholder("模糊搜索")).send_keys(order_code) base.wait_element_click(base.find_xpath("批量审核")) base.wait_element(base.find_xpath("提示", "根据当前查询条件共查询出")) time.sleep(1) base.wait_element_click(base.find_xpath("根据当前查询条件共查询出", "确定")) base.change_frame("全部订单框架", "任务托管列表") base.wait_text_locate(base.get_cell_xpath(1, "进度条"), '100%') base.change_frame("全部订单框架") base.wait_element_click(base.find_xpath_by_tag_name("任务托管列表", "a"))
def modify_note(keyword, modify_info): """ key_word:关键字,比如order_code modify_info = {"便签": "111", "追加": True, "系统便签":"爆款订单", "常用便签": "常用便签1", "维护常用便签": "常用便签1:红旗,常用便签2:黄,常用便签3:蓝"} """ with base.wait_refresh(base.get_cell_xpath(keyword, "便签")) as e: base.wait_element_click(base.find_xpath("修改&标记")) base.wait_element_click(base.find_xpath("修改&标记", "修改便签")) base.change_frame("全部订单框架", "修改订单便签") for k, v in modify_info.items(): if k == "便签": base.wait_element( base.find_xpath_by_tag_name( "选择的", "textarea", True)).send_keys(Keys.CONTROL + 'a') base.wait_element( base.find_xpath_by_tag_name("选择的", "textarea", True)).send_keys(v) elif k == "追加": element = base.wait_element( base.find_xpath_by_inner_tag_name("追加便签", "input")) is_select = element.is_selected() print(f"输入的值是{v}") print(f"元素是否被选中{is_select}") print(f"是否相等{is_select == v}") if is_select != v: base.wait_element_click( base.find_xpath_by_inner_tag_name("追加便签", "input")) elif k == "系统便签": base.wait_element(base.find_xpath("系统标签", v)) time.sleep(1) base.wait_element_click(base.find_xpath("系统标签", v)) elif k == "常用便签": base.wait_element(base.find_xpath("常用标签", v)) time.sleep(1) base.wait_element_click(base.find_xpath("常用标签", v)) elif k == "维护常用便签": base.wait_element_click(base.find_xpath("维护常用便签")) base.wait_element( base.find_xpath_by_placeholder("请输入常用便签(逗号分隔)")).send_keys( Keys.CONTROL + 'a') base.wait_element( base.find_xpath_by_placeholder("请输入常用便签(逗号分隔)")).send_keys( v) base.wait_element_click(base.find_xpath("维护常用便签", "确认")) base.change_frame("全部订单框架") base.wait_element_click(base.find_xpath("修改订单便签", "保存"))
def modify_address(keyword, modify_info): """ key_word:关键字,比如order_code modify_info = {"收货地址": "江苏省南京市鼓楼区鼓楼大道1185号", "收货人名": "aaaaa", "联系电话":"BBBBBB", "联系手机": "13772839830", "邮政编码": "211458","核对备注","11111111111111","选择地址": "会员名,手机号,地址"} """ base.scroll_to(4) with base.wait_refresh(base.get_cell_xpath(keyword, "地址")) as e: base.wait_element_click(base.find_xpath("修改&标记")) base.wait_element_click(base.find_xpath("修改&标记", "修改地址")) base.change_frame("修改地址") for k, v in modify_info.items(): if k == "收货地址": base.wait_element( base.find_xpath_by_tag_name( "收货地址", "input[7]")).send_keys(Keys.CONTROL + 'a') base.wait_element( base.find_xpath_by_tag_name("收货地址", "input[7]")).send_keys(v) base.wait_element( base.find_xpath_by_tag_name("收货地址", "input[7]")).send_keys( Keys.ENTER) time.sleep(1) elif k == "收货人名": base.wait_element(base.find_xpath_by_tag_name( "收货人名", "input")).send_keys(Keys.CONTROL + 'a') base.wait_element(base.find_xpath_by_tag_name( "收货人名", "input")).send_keys(v) elif k == "联系电话": base.wait_element(base.find_xpath_by_tag_name( "联系电话", "input")).send_keys(Keys.CONTROL + 'a') base.wait_element(base.find_xpath_by_tag_name( "联系电话", "input")).send_keys(v) elif k == "联系手机": base.wait_element(base.find_xpath_by_tag_name( "联系手机", "input")).send_keys(Keys.CONTROL + 'a') base.wait_element(base.find_xpath_by_tag_name( "联系手机", "input")).send_keys(v) elif k == "邮政编码": base.wait_element(base.find_xpath_by_tag_name( "邮政编码", "input")).send_keys(Keys.CONTROL + 'a') base.wait_element(base.find_xpath_by_tag_name( "邮政编码", "input")).send_keys(v) elif k == "选择地址": base.wait_element(base.find_xpath("地址", v)) time.sleep(1) base.wait_element_click(base.find_xpath("地址", v)) elif k == "核对备注": seller_memo = base.wait_element( base.find_xpath_by_tag_name( "卖家备注", "textarea")).get_attribute("value") print(f"{seller_memo}") assert seller_memo == v base.change_frame() base.wait_element_click(base.find_xpath("修改地址", "确定")) base.change_frame("全部订单框架")
def turn_to_exception(exception_type, exception_description='', normal_exceptions='常用异常1,常用异常2,常用异常3'): """ exception_type:异常类型 目前仅支持常用异常,黑名单,终结,标记异常 exception_description:异常描述,当使用常用异常时,用于指定是哪个常用异常 normal_exceptions:用于直接覆盖常用异常枚举 """ base.wait_element_click(base.find_xpath("转异常")) base.change_frame("全部订单框架", "请输入标记异常的类型,输入相关说明") if exception_type == '常用异常': base.wait_element_click(base.find_xpath("维护常用异常")) base.change_frame("全部订单框架") base.wait_element(base.find_xpath_by_placeholder( "请输入常用异常(逗号分隔)")).send_keys(Keys.CONTROL + 'a') base.wait_element(base.find_xpath_by_placeholder( "请输入常用异常(逗号分隔)")).send_keys(normal_exceptions) base.wait_element_click(base.find_xpath("维护常用异常", "确认")) base.change_frame("全部订单框架", "请输入标记异常的类型,输入相关说明") time.sleep(1) base.wait_element_click(base.find_xpath("常用异常", exception_description)) elif exception_type in ["黑名单", "终结", "标记异常"]: base.wait_element_click(base.find_xpath(exception_type)) if exception_description != '': base.wait_element(base.find_xpath_by_tag_name( "异常描述:", "input")).send_keys(Keys.CONTROL + 'a') base.wait_element(base.find_xpath_by_tag_name( "异常描述:", "input")).send_keys(exception_description) else: assert 1 == 2, "请核实异常类型是否正确,目前仅支持常用异常,黑名单,终结,标记异常" base.change_frame("全部订单框架") base.wait_element_click(base.find_xpath("请输入标记异常的类型,输入相关说明", "确认")) if exception_type == '终结': base.wait_element(base.find_xpath("是否终结", "确定")) time.sleep(1) base.wait_element_click(base.find_xpath("是否终结", "确定"))
def test_category_search_condition(): category_list = ["裤子", "上衣"] for category in category_list: print(f"本次搜索的分类:{category}") base.wait_element_click(base.find_xpath_by_placeholder("商品分类")) base.change_frame("选择分类") base.wait_element(base.find_xpath(category)) time.sleep(1) base.wait_element_click(base.find_xpath(category)) base.change_frame() base.wait_element_click(base.find_xpath("选择分类", "确定")) base.change_frame("库存查询框架") base.wait_table_refresh(base.find_xpath("组合查询"), 1, "商家编码") result_num = base.wait_element(base.find_xpath("已选择", "本页共")).text if result_num == '本页共0条数据': print(f"没数据不用查看") else: result = base.get_unique_column_text("货号") for product_code in result: category_result = product_interface.get_sku_info( product_code)["data"]["Items"][0]["ProductCategory"] print(f"本次搜索的货号:{product_code}的分类是{category_result}") assert category_result == category
def test_supplier_name_search_condition(): supplier_name_list = ["供应商1", "供应商2", "供应商3", "供应商4", "供应商5"] for supplier_name in supplier_name_list: base.wait_element_click(base.find_xpath_by_placeholder("供应商")) base.change_frame("选择供应商") base.chose_supplier_by_text(supplier_name) base.change_frame() base.wait_element_click(base.find_xpath("选择供应商", "确定")) base.change_frame("库存查询框架") base.wait_element(base.find_xpath('组合查询')) time.sleep(1) base.wait_table_refresh(base.find_xpath('组合查询'), 1, "货号") result_num = base.wait_element(base.find_xpath("已选择", "本页共")).text if result_num == '本页共0条数据': print(f"供应商[{supplier_name}]没数据不用查看") else: result = base.get_column_text("商家编码") for i in result: if "+" in i: continue print(f"需要校验供应商的商家编码:{i}") name = product_interface.get_sku_info( i)["data"]["Items"][0]["SupplierName"] assert supplier_name == name
def test_vip_price_detail(): # 先确定下设置 setting_info = { "记录会员上次交易价:手工单或者门店单保存时,记录会员的商品交易价格": "true", "记录会员上次交易价 同款同价:手工单或者门店单保存时,记录会员的商品交易价格 同款同价": "false", "只有手工修改售价才会记录预设价格": "true", } interface.save_order_setting(setting_info) print("这就为了换个行") print("非同款同价模式+修改才记录会员价设置完成,修改设置之后等5秒,让设置生效") time.sleep(5) base.close_page("预设会员价明细") base.open_page("会员", "预设会员价明细", "预设会员价明细框架") # 新建会员 vip_name = base.get_now_string() print(f"新建一个会员,会员名称:{vip_name}") interface.new_vip(vip_name) print(f"新建的会员:{vip_name}在预设会员价页面没有任何记录") # 查询确认新会员没有任何记录 base.wait_element(base.find_xpath_by_placeholder("会员")).click() base.change_frame("预设会员价明细框架") base.switch_to_frame(base.find_frame("选择会员")) base.chose_vip(vip_name) base.change_frame("预设会员价明细框架") base.wait_element(base.find_xpath("本页共0条数据")) print(f"新建会员:{vip_name}确定在预设会员价页面没有任何记录") # 新建商品 product_code = base.get_now_string() print(f"新建商品货号:{product_code}") # 新建商品 interface.new_product(product_code) # 获取一个sku_code查看会员价格 sku_code = interface.get_sku_code(product_code)[0] print(f"取出一个商品:{sku_code}查看售价,此时售价应该为0") with base.operate_page("订单", "门店收银", "门店收银框架") as e: base.change_frame("门店收银框架", "选择会员") base.chose_vip(vip_name) base.change_frame("门店收银框架") base.wait_element_focus(base.find_xpath_by_placeholder("请扫描商品条码")) base.wait_element( base.find_xpath_by_placeholder("商品货号")).send_keys(product_code) base.wait_element(base.find_xpath("搜索")).click() time.sleep(1) base.wait_element(base.find_xpath(product_code)).click() base.change_frame("门店收银框架") base.switch_to_frame(base.find_frame("商品选择")) price = base.wait_element( base.get_old_cell_input_xpath("红色 XS", "交易价格")).get_attribute("value") assert price == '0' print(f"确定{sku_code}的售价是0") # 设置商品的标准售价,第二价格,第三价格,第四价格 interface.modify_sku_price(sku_code, "100", "200", "300", "400") print(f"设置{sku_code}的价格分别为100,200,300,400,此时商品的价格应该是100") # 再次到门店开单页面查看售价是否是标准售价=100 with base.operate_page("订单", "门店收银", "门店收银框架") as e: base.change_frame("门店收银框架", "选择会员") base.chose_vip(vip_name) base.change_frame("门店收银框架") base.wait_element_focus(base.find_xpath_by_placeholder("请扫描商品条码")) base.wait_element( base.find_xpath_by_placeholder("商品货号")).send_keys(product_code) base.wait_element(base.find_xpath("搜索")).click() time.sleep(1) base.wait_element(base.find_xpath(product_code)).click() base.change_frame("门店收银框架") base.switch_to_frame(base.find_frame("商品选择")) price = base.wait_element( base.get_old_cell_input_xpath("红色 XS", "交易价格")).get_attribute("value") assert price == '100' print(f"确定{sku_code}的售价是100") # 设置会员等级为8折,再次查看售价是否是80 print(f"将会员{vip_name}的会员等级设置为8折,此时售价应该是100*0.8") vip_level = "8折" interface.modify_vip_level(vip_name, vip_level) with base.operate_page("订单", "门店收银", "门店收银框架") as e: base.change_frame("门店收银框架", "选择会员") base.chose_vip(vip_name) base.change_frame("门店收银框架") base.wait_element_focus(base.find_xpath_by_placeholder("请扫描商品条码")) base.wait_element( base.find_xpath_by_placeholder("商品货号")).send_keys(product_code) base.wait_element(base.find_xpath("搜索")).click() time.sleep(1) base.wait_element(base.find_xpath(product_code)).click() base.change_frame("门店收银框架") base.switch_to_frame(base.find_frame("商品选择")) price = base.wait_element( base.get_old_cell_input_xpath("红色 XS", "交易价格")).get_attribute("value") assert price == '80' print(f"确定会员:{vip_name}商品{sku_code}的售价是80") # 门店开单,不修改商品价格,还是没有记录 # sku_info_list 商品信息列表 sku_info_list = [] sku_info = {} product_info = interface.get_sku_info('', product_code) i = 1 for sku in product_info["data"]["Items"]: sku_info["SkuCode"] = sku["SkuCode"] i += 1 sku_info["Qty"] = i sku_info["Price"] = int(sku["StandardPrice"]) * int( interface.get_vip_level_info(vip_level)["data"]["Items"][0] ["Discount"]) / 10 sku_info_list.append(dict(sku_info)) print("不改变任何sku价格是商品明细列表信息:") for i in sku_info_list: print(i) print("不修改sku价格,预设会员价明细页面不应该有任何记录") # 商品数据确定之后直接开单 interface.new_pos_oder(vip_name, sku_info_list) # 再次核对预设会员价明细页面还是0 base.open_page("会员", "预设会员价明细", "预设会员价明细框架") base.wait_element(base.find_xpath_by_placeholder("会员")).click() base.change_frame("预设会员价明细框架") base.switch_to_frame(base.find_frame("选择会员")) base.chose_vip(vip_name) base.change_frame("预设会员价明细框架") time.sleep(1) base.wait_element(base.find_xpath("本页共0条数据")) print("确定不修改售价不会有任何记录") # 再次开单,修改其中一个规则的价格,必须有一条记录 # 修改商品信息 modify_info = {} for i in range(0, 1): modify_sku_code = sku_info_list[i]["SkuCode"] modify_price = sku_info_list[i]["Price"] + 10 sku_info_list[i]["Price"] = copy.copy(modify_price) modify_info[modify_sku_code] = modify_price for k, v in modify_info.items(): print(f"修改{k}的价格为{v}") for i in sku_info_list: print(i) print("修改一个商品的售价之后,预设会员价明细页面应该有一条记录") # 商品数据确定之后直接开单 interface.new_pos_oder(vip_name, sku_info_list) # 再次核对预设会员价明细页面有一条记录 base.open_page("会员", "预设会员价明细", "预设会员价明细框架") base.wait_element(base.find_xpath_by_placeholder("会员")).click() base.change_frame("预设会员价明细框架") base.switch_to_frame(base.find_frame("选择会员")) base.chose_vip(vip_name) base.change_frame("预设会员价明细框架") time.sleep(2) base.wait_element(base.find_xpath("本页共1条数据")) result = base.get_column_text("商家编码") assert len(result) == 1 for r in result: assert r in modify_info.keys() vip_price = base.wait_element(base.get_cell_xpath(r, "预设价格")).text assert float(modify_info[r]) == float(vip_price) print("修改一个商品的售价之后,预设会员价页面记录的只有一条记录,并且sku_code,预设价格核对无误") # 修改两个规格的价格,预设会员价明细页面会有两条明细 # 还是先修改商品价格 modify_info.clear() j = 10 for i in range(0, 2): modify_sku_code = sku_info_list[i]["SkuCode"] j += 7 modify_price = sku_info_list[i]["Price"] + j sku_info_list[i]["Price"] = modify_price modify_info[modify_sku_code] = modify_price for k, v in modify_info.items(): print(f"修改{k}的价格为{v}") print("修改两个sku价格之后的商品信息列表是:") for i in sku_info_list: print(i) print("修改两个商品价格之后开单,会员预设价页面应该有两条数据") # 商品数据确定之后直接开单 interface.new_pos_oder(vip_name, sku_info_list) # 再次核对预设会员价明细页面有两条记录 base.open_page("会员", "预设会员价明细", "预设会员价明细框架") base.wait_element(base.find_xpath_by_placeholder("会员")).click() base.change_frame("预设会员价明细框架") base.switch_to_frame(base.find_frame("选择会员")) base.chose_vip(vip_name) base.change_frame("预设会员价明细框架") time.sleep(1) base.wait_element(base.find_xpath("本页共2条数据")) result = base.get_column_text("商家编码") assert len(result) == 2 for r in result: assert r in modify_info.keys() vip_price = base.wait_element(base.get_cell_xpath(r, "预设价格")).text assert float(modify_info[r]) == float(vip_price) print("修改两个商品之后开单,会员预设价页面只有两条记录,商家编码,预设价格经核实无误") # 全部更改则需要显示全部该商品的全部记录 modify_info.clear() for i in sku_info_list: modify_sku_code = i["SkuCode"] j += 5 modify_price = i["Price"] + j i["Price"] = modify_price modify_info[modify_sku_code] = modify_price for k, v in modify_info.items(): print(f"修改{k}的价格为:{v}") print("修改全部商品价格之后的商品信息列表是:") for i in sku_info_list: print(i) print("修改全部商品的价格之后,预设会员价页面应该有该款所有商品的记录") # 商品数据确定之后直接开单 interface.new_pos_oder(vip_name, sku_info_list) # 再次核对预设会员价明细页面有两条记录 base.open_page("会员", "预设会员价明细", "预设会员价明细框架") base.wait_element(base.find_xpath_by_placeholder("会员")).click() base.change_frame("预设会员价明细框架") base.switch_to_frame(base.find_frame("选择会员")) base.chose_vip(vip_name) base.change_frame("预设会员价明细框架") time.sleep(1) base.wait_element(base.find_xpath(f"本页共{len(sku_info_list)}条数据")) result = base.get_column_text("商家编码") assert len(result) == len(sku_info_list) for r in result: assert r in modify_info.keys() vip_price = base.wait_element(base.get_cell_xpath(r, "预设价格")).text assert float(modify_info[r]) == float(vip_price) print("预设会员价页面有该款商品的全部记录,并且商家编码预设价格核对无误") print("在选择会员的情况下,核实下标准售价,第二价格,第三价格,第四价格,会员价格取值是否正确") result = base.get_column_text("标准售价") for r in result: print(f"标准售价应该是100实际是:{r},") assert r == '100' result = base.get_column_text("第二价格") for r in result: print(f"第二价格应该是200实际是:{r},") assert r == '200' result = base.get_column_text("第三价格") for r in result: print(f"第三价格应该是300实际是:{r},") assert r == '300' result = base.get_column_text("第四价格") for r in result: print(f"第四价格应该是400实际是:{r},") assert r == '400' result = base.get_column_text("会员价") for r in result: print(f"会员价应该是80实际是:{r},") assert r == '80' print("确定在选择会员的情况下,核实下标准售价,第二价格,第三价格,第四价格,会员价格取值是否正确") print("清空搜索条件之后,搜索货号,查看所有价格的取值是否正确") base.wait_table_refresh(base.find_xpath("清空"), 1, "货号") base.wait_element_click( base.find_xpath_by_placeholder("商品货号")).send_keys(product_code) base.wait_table_refresh(base.find_xpath("组合查询"), 1, "货号") result = base.get_column_text("标准售价") for r in result: print(f"标准售价应该是100实际是:{r},") assert r == '100' result = base.get_column_text("第二价格") for r in result: print(f"第二价格应该是200实际是:{r},") assert r == '200' result = base.get_column_text("第三价格") for r in result: print(f"第三价格应该是300实际是:{r},") assert r == '300' result = base.get_column_text("第四价格") for r in result: print(f"第四价格应该是400实际是:{r},") assert r == '400' result = base.get_column_text("会员价") for r in result: print(f"会员价应该是80实际是:{r},") assert r == '80' print("确定清空搜索条件之后,搜索货号,查看所有价格的取值是否正确") # 修改设置,再来一遍 print("修改设置为同款同价再跑一遍") print("修改设置为同款同价再跑一遍") print("修改设置为同款同价再跑一遍") setting_info = { "记录会员上次交易价:手工单或者门店单保存时,记录会员的商品交易价格": "true", "记录会员上次交易价 同款同价:手工单或者门店单保存时,记录会员的商品交易价格 同款同价": "true", "只有手工修改售价才会记录预设价格": "true", } interface.save_order_setting(setting_info) print("同款同价模式且只有修改时记录会员价格设置完成,") print("修改设置之后等待5秒等设置生效") time.sleep(5) base.close_page("预设会员价明细") base.open_page("会员", "预设会员价明细", "预设会员价明细框架") # 新建会员 vip_name = base.get_now_string() print(f"新建会员会员名称:{vip_name}") interface.new_vip(vip_name) # 查询确认新会员没有任何记录 base.wait_element(base.find_xpath_by_placeholder("会员")).click() base.change_frame("预设会员价明细框架") base.switch_to_frame(base.find_frame("选择会员")) base.chose_vip(vip_name) base.change_frame("预设会员价明细框架") base.wait_element(base.find_xpath("本页共0条数据")) # 新建商品 product_code = base.get_now_string() print(f"新建商品货号:{product_code}") # 解析出第一个skuCode print("验证没有设置价格时,售价为0") sku_code = interface.new_product( product_code)["data"]["ProductSkus"][0]["Code"] with base.operate_page("订单", "门店收银", "门店收银框架") as e: base.change_frame("门店收银框架", "选择会员") base.chose_vip(vip_name) base.change_frame("门店收银框架") base.wait_element_focus(base.find_xpath_by_placeholder("请扫描商品条码")) base.wait_element( base.find_xpath_by_placeholder("商品货号")).send_keys(product_code) base.wait_element(base.find_xpath("搜索")).click() time.sleep(1) base.wait_element(base.find_xpath(product_code)).click() base.change_frame("门店收银框架") base.switch_to_frame(base.find_frame("商品选择")) price = base.wait_element( base.get_old_cell_input_xpath("红色 XS", "交易价格")).get_attribute("value") assert price == '0' or price is None print("确定没有设置价格时,售价为0") # 设置商品的标准售价,第二价格,第三价格,第四价格 interface.modify_sku_price(sku_code, "100", "200", "300", "400") # 再次到门店开单页面查看售价是否是标准售价=100 print("验证标准售价设置为100,之后售价应该为100") with base.operate_page("订单", "门店收银", "门店收银框架") as e: base.change_frame("门店收银框架", "选择会员") base.chose_vip(vip_name) base.change_frame("门店收银框架") base.wait_element_focus(base.find_xpath_by_placeholder("请扫描商品条码")) base.wait_element( base.find_xpath_by_placeholder("商品货号")).send_keys(product_code) base.wait_element(base.find_xpath("搜索")).click() time.sleep(1) base.wait_element(base.find_xpath(product_code)).click() base.change_frame("门店收银框架") base.switch_to_frame(base.find_frame("商品选择")) price = base.wait_element( base.get_old_cell_input_xpath("红色 XS", "交易价格")).get_attribute("value") assert price == '100' print("确定标准售价设置为100,之后售价应该为100") print("验证会员等级设置为8折之后,售价应该是80") # 设置会员等级为8折,再次查看售价是否是80 vip_level = "8折" interface.modify_vip_level(vip_name, vip_level) with base.operate_page("订单", "门店收银", "门店收银框架") as e: base.change_frame("门店收银框架", "选择会员") base.chose_vip(vip_name) base.change_frame("门店收银框架") base.wait_element_focus(base.find_xpath_by_placeholder("请扫描商品条码")) base.wait_element( base.find_xpath_by_placeholder("商品货号")).send_keys(product_code) base.wait_element(base.find_xpath("搜索")).click() time.sleep(1) base.wait_element(base.find_xpath(product_code)).click() base.change_frame("门店收银框架") base.switch_to_frame(base.find_frame("商品选择")) price = base.wait_element( base.get_old_cell_input_xpath("红色 XS", "交易价格")).get_attribute("value") assert price == '80' print("确定会员等级设置为8折之后,售价应该是80") # 门店开单,不修改商品价格,还是没有记录 # sku_info_list 商品信息列表 sku_info_list = [] sku_info = {} product_info = interface.get_sku_info('', product_code) i = 1 for sku in product_info["data"]["Items"]: sku_info["SkuCode"] = sku["SkuCode"] i += 1 sku_info["Qty"] = i sku_info["Price"] = int(sku["StandardPrice"]) * int( interface.get_vip_level_info(vip_level)["data"]["Items"][0] ["Discount"]) / 10 sku_info_list.append(dict(sku_info)) print("不改变任何sku价格是商品明细列表信息:") for i in sku_info_list: print(i) print("验证不改变商品售价时,预设会员价页面没有记录") # 商品数据确定之后直接开单 interface.new_pos_oder(vip_name, sku_info_list) # 再次核对预设会员价明细页面还是0 base.open_page("会员", "预设会员价明细", "预设会员价明细框架") base.wait_element(base.find_xpath_by_placeholder("会员")).click() base.change_frame("预设会员价明细框架") base.switch_to_frame(base.find_frame("选择会员")) base.chose_vip(vip_name) base.change_frame("预设会员价明细框架") time.sleep(1) base.wait_element(base.find_xpath("本页共0条数据")) # 再次开单,修改其中一个规则的价格,必须有一条记录 print("确定不改变商品售价时,预设会员价页面没有记录") print("验证修改一个商品售价之后,预设会员价页面有该款记录") # 修改商品信息 modify_info = {} for i in range(0, 1): modify_sku_code = sku_info_list[i]["SkuCode"] modify_price = sku_info_list[i]["Price"] + 10 sku_info_list[i]["Price"] = copy.copy(modify_price) modify_info[modify_sku_code] = modify_price for k, v in modify_info.items(): print(f"修改{k}的价格为{v}") for i in sku_info_list: print(i) # 商品数据确定之后直接开单 interface.new_pos_oder(vip_name, sku_info_list) # 再次核对预设会员价明细页面有一条记录 base.open_page("会员", "预设会员价明细", "预设会员价明细框架") base.wait_element(base.find_xpath_by_placeholder("会员")).click() base.change_frame("预设会员价明细框架") base.switch_to_frame(base.find_frame("选择会员")) base.chose_vip(vip_name) base.change_frame("预设会员价明细框架") time.sleep(2) base.wait_element(base.find_xpath("本页共1条数据")) result = base.get_column_text("货号") assert len(result) == 1 for r in result: assert r == product_code vip_price = base.wait_element(base.get_cell_xpath(r, "预设价格")).text assert float(vip_price) in modify_info.values() print("确定修改一个商品售价之后,预设会员价页面有该款记录") print("修改整款商品价格之后,预设会员价页面也只有一个价格") # 修改所有商品价格 modify_info.clear() for i in sku_info_list: modify_sku_code = i["SkuCode"] j += 5 modify_price = 195 i["Price"] = modify_price modify_info[modify_sku_code] = modify_price for k, v in modify_info.items(): print(f"修改{k}的价格为:{v}") print("修改全部商品价格之后的商品信息列表是:") for i in sku_info_list: print(i) # 商品数据确定之后直接开单 interface.new_pos_oder(vip_name, sku_info_list) base.open_page("会员", "预设会员价明细", "预设会员价明细框架") base.wait_element(base.find_xpath_by_placeholder("会员")).click() base.change_frame("预设会员价明细框架") base.switch_to_frame(base.find_frame("选择会员")) base.chose_vip(vip_name) base.change_frame("预设会员价明细框架") time.sleep(1) base.wait_element(base.find_xpath("本页共1条数据")) result = base.get_column_text("货号") assert len(result) == 1 for r in result: assert r == product_code vip_price = base.wait_element(base.get_cell_xpath(r, "预设价格")).text assert float(vip_price) in modify_info.values() print("修改整款商品价格之后,预设会员价页面也只有一个价格") print("预设会员价页面有该款商品的全部记录,并且商家编码预设价格核对无误") print("在选择会员的情况下,核实下标准售价,第二价格,第三价格,第四价格,会员价格取值是否正确") result = base.get_column_text("标准售价") for r in result: print(f"标准售价应该是100实际是:{r},") assert r == '100' result = base.get_column_text("第二价格") for r in result: print(f"第二价格应该是200实际是:{r},") assert r == '200' result = base.get_column_text("第三价格") for r in result: print(f"第三价格应该是300实际是:{r},") assert r == '300' result = base.get_column_text("第四价格") for r in result: print(f"第四价格应该是400实际是:{r},") assert r == '400' result = base.get_column_text("会员价") for r in result: print(f"会员价应该是80实际是:{r},") assert r == '80' print("确定在选择会员的情况下,核实下标准售价,第二价格,第三价格,第四价格,会员价格取值是否正确") print("清空搜索条件之后,搜索货号,查看所有价格的取值是否正确") base.wait_table_refresh(base.find_xpath("清空"), 1, "货号") base.wait_element_click( base.find_xpath_by_placeholder("商品货号")).send_keys(product_code) base.wait_table_refresh(base.find_xpath("组合查询"), 1, "货号") result = base.get_column_text("标准售价") for r in result: print(f"标准售价应该是100实际是:{r},") assert r == '100' result = base.get_column_text("第二价格") for r in result: print(f"第二价格应该是200实际是:{r},") assert r == '200' result = base.get_column_text("第三价格") for r in result: print(f"第三价格应该是300实际是:{r},") assert r == '300' result = base.get_column_text("第四价格") for r in result: print(f"第四价格应该是400实际是:{r},") assert r == '400' result = base.get_column_text("会员价") for r in result: print(f"会员价应该是80实际是:{r},") assert r == '80' print("确定清空搜索条件之后,搜索货号,查看所有价格的取值是否正确")
def test_detail_button(): """ 能显示字段即可,不管功能 """ sku_code = "测试商品1-红色 XS" base.scroll_to(4) time.sleep(1) base.wait_element( base.find_xpath_by_placeholder("商家编码")).send_keys(Keys.CONTROL + 'a') base.wait_element( base.find_xpath_by_placeholder("商家编码")).send_keys(sku_code) base.wait_table_refresh(base.find_xpath("组合查询"), 1, "余额") base.wait_element_click(base.get_cell_xpath(1, ["库存预警值", "库存数"])) base.wait_element_click(base.get_cell_xpath(1, ["库存预警值", "库存数"], "详")) base.change_frame("库存查询框架", "出入库记录页面") base.wait_element(base.find_xpath("调整金额")) base.change_frame("库存查询框架") time.sleep(1) base.wait_element_click(base.find_xpath_by_tag_name("出入库记录页面", "a")) base.wait_element_click(base.get_cell_xpath(1, ["余额", "占用数"])) base.wait_element_click(base.get_cell_xpath(1, ["余额", "占用数"], "详")) base.change_frame("库存查询框架", "占用记录页面") base.wait_element(base.find_xpath("订单单号")) base.change_frame("库存查询框架") base.wait_element(base.find_xpath_by_tag_name("占用记录页面", "a")) time.sleep(1) base.wait_element_click(base.find_xpath_by_tag_name("占用记录页面", "a")) time.sleep(1) base.wait_element_click(base.get_cell_xpath(1, "采购在途数")) base.wait_element_click(base.get_cell_xpath(1, "采购在途数", "详")) base.change_frame("库存查询框架", "在途采购单明细页面") base.wait_element(base.find_xpath("采购单编码")) base.change_frame("库存查询框架") base.wait_element(base.find_xpath_by_tag_name("在途采购单明细页面", "a")) time.sleep(1) base.wait_element_click(base.find_xpath_by_tag_name("在途采购单明细页面", "a")) base.wait_element_click(base.get_cell_xpath(1, "操作", "销售链接")) base.change_frame("库存查询框架", "销售链接明细") base.wait_element(base.find_xpath("店铺")) base.change_frame("库存查询框架") base.wait_element(base.find_xpath_by_tag_name("销售链接明细", "a")) time.sleep(1) base.wait_element_click(base.find_xpath_by_tag_name("销售链接明细", "a")) base.wait_element_click(base.get_cell_xpath(1, "操作", "销售订单")) base.change_frame("库存查询框架", "销售订单明细") base.wait_element(base.find_xpath("平台单号"))
def test_new_order(): base.wait_element(base.find_xpath("新增订单")) time.sleep(1) base.wait_element_click(base.find_xpath("新增订单")) base.wait_element_click(base.find_xpath_with_spaces("手工新增订单")) base.change_frame("全部订单框架", "创建新订单") base.wait_element_click(base.find_xpath("阿里测试店铺01")) base.wait_element_click(base.find_xpath("选择买家", "选择买家")) base.change_frame("全部订单框架", "选择买家") print(f"该页面单击直接勾选") base.wait_element(base.find_xpath("加载", "渲染")) base.wait_element_click(base.get_cell_xpath(1, "所属平台")) base.change_frame("全部订单框架") base.wait_element_click(base.find_xpath("选择买家", "确认选择的买家")) base.change_frame("全部订单框架", "创建新订单") base.wait_element(base.find_xpath_by_tag_name("买家留言", "input")).send_keys("买家留言") base.wait_element(base.find_xpath_by_tag_name("卖家备注", "input")).send_keys("卖家备注") base.change_frame("全部订单框架") base.wait_element_click(base.find_xpath("确认并创建新的订单")) base.wait_element(base.find_xpath("增加新的商品")) order_code = base.wait_element(base.get_cell_xpath(1, "订单编码")).text base.wait_element_click(base.find_xpath("增加新的商品")) base.change_frame("全部订单框架", "选择商品") base.chose_product_by_text("测试商品1-红色 XS,测试商品1-红色 S") base.change_frame("全部订单框架") base.wait_element_click(base.find_xpath("选择商品", "确定")) base.wait_element(base.get_cell_xpath(1, "订单编码")) time.sleep(2) base.wait_element_click(base.get_cell_xpath(1, "订单编码")) base.wait_element_click(base.get_cell_xpath(1, "订单编码", "详")) base.change_frame("全部订单框架", "订单详情") base.wait_element_click(base.find_xpath("快速支付")) base.wait_element(base.find_xpath("确认快速添加支付明细吗?")) time.sleep(1) base.wait_element_click(base.find_xpath("确认快速添加支付明细吗?", "确定")) base.wait_element(base.find_xpath("支付账号", "支付日期")) base.change_frame("全部订单框架") base.wait_element_click(base.find_xpath_by_tag_name("订单详情", "a")) order_status = base.wait_element(base.get_cell_xpath(1, "订单状态")).text assert order_status == '待审核'