def basic_cloud_act(self, business, username, password, product_codes): basePage.login(self, business, username, password) self.driver.wait_activity(".bash.ui.MainActivity", 10) while True: update_info = self.find_element(basePage.update_text_info) time.sleep(2) if not update_info: break try: self.click_element(basePage.menu_btn_layout) page_size = basePage.GetPageSize(self) sx = 0.1 sy = 0.75 ex = 0.1 ey = 0.25 basePage.swipe_up(self, page_size, sx, sy, ex, ey) self.click_element(coLocation.module_item_name, timeout=1) # ===================>>>>>>>我的云单<<<<<<<<=============================== self.order_list() # ===================>>>>>>>门店指标<<<<<<<<=============================== except Exception as e: raise Exception('报表查询操作出现异常')
def basic_dashboard_act(self, business, username, password): basePage.login(self, business, username, password) self.driver.wait_activity(".bash.ui.MainActivity", 10) while True: update_info = self.find_element(basePage.update_text_info) time.sleep(2) if not update_info: break try: self.click_element(basePage.menu_btn_layout) self.click_element(dbLocation.module_item_name, timeout=4) contexts = self.driver.contexts self.driver.switch_to.context(contexts[1]) time.sleep(4) # ===================>>>>>>>门店销售<<<<<<<<=============================== self.shop_sale() # ===================>>>>>>>门店指标<<<<<<<<=============================== self.shop_indicator() # ===================>>>>>>>门店周报<<<<<<<<=============================== self.shop_weekly() # ===================>>>>>>>库存分析<<<<<<<<=============================== self.inventory_indicator() except Exception as e: print e raise Exception('数据罗盘操作出现异常')
def scrap_create(self, business, username, password, product_codes): basePage.login(self, business, username, password) self.driver.wait_activity(".bash.ui.MainActivity", 10) while True: update_info = self.find_element(basePage.update_text_info) time.sleep(2) if not update_info: break try: # 点击菜单 self.click_element(basePage.menu_btn_layout) # 向上滑到页面 page_size = basePage.GetPageSize(self) sx = 0.1 sy = 0.75 ex = 0.1 ey = 0.25 basePage.swipe_up(self, page_size, sx, sy, ex, ey) # 点击库存损益 self.click_element(sLocation.scrap) time.sleep(5) self.click_element(sLocation.stock_loss_add) self.click_element(sLocation.product_type_edit) self.click_element(sLocation.change_product) self.click_element(sLocation.stock_type_edit) self.click_element(sLocation.change_reason) self.input_element(sLocation.resean_edit, '123') self.click_element(sLocation.stock_loss_next) time.sleep(6) contexts = self.driver.contexts self.switch_h5(contexts[1]) time.sleep(4) self.click_element(sLocation.add_handle) time.sleep(4) for code in product_codes: contexts = self.driver.contexts self.switch_h5(contexts[0]) time.sleep(7) self.click_element(sLocation.search_product) for num in code: self.driver.press_keycode(basePage.keycode[num]) self.click_element(basePage.keypad_search_btn) contexts = self.driver.contexts self.switch_h5(contexts[1]) time.sleep(4) self.click_element(sLocation.product_colors) self.click_element(sLocation.product_size) self.click_element(sLocation.add) self.click_element(sLocation.back_btn) self.click_element(sLocation.confirm) self.click_element(sLocation.back_btn) contexts = self.driver.contexts self.switch_h5(contexts[0]) time.sleep(6) self.click_element(basePage.menu_btn_layout) page_size = basePage.GetPageSize(self) basePage.swipe_up(self, page_size, 0.1, 0.80, 0.1, 0.10) self.click_element(basePage.logout) self.click_element(basePage.text_confirm) except Exception as e: raise Exception('创建损益单时出现异常:%s' % e)
def transfer_confirm(self, business, username, password): ''' 签收待签收的单据 :param business: :param username: :param password: :return: ''' basePage.login(self, business, username, password) self.driver.wait_activity(".bash.ui.MainActivity", 10) while True: update_info = self.find_element(basePage.update_text_info) print update_info time.sleep(2) if update_info == False: break try: # 点击菜单 self.click_element(basePage.menu_btn_layout) # 向上滑到页面 page_size = basePage.GetPageSize(self) sx = 0.1 sy = 0.75 ex = 0.1 ey = 0.25 basePage.swipe_up(self, page_size, sx, sy, ex, ey) # 点击门店入库 self.click_element(tranLocation.stock_in) # 点击调拨入库 self.click_element(tranLocation.transfer_in) time.sleep(5) self.click_element(tranLocation.details_text) contexts = self.driver.contexts self.switch_h5(contexts[1]) time.sleep(4) self.click_element(tranLocation.icon_edit) self.click_element(tranLocation.icon_delete) self.click_element(tranLocation.num_key) self.click_element(tranLocation.key_confirm) self.click_element(tranLocation.btn_save) self.click_element(tranLocation.back_btn) time.sleep(4) contexts = self.driver.contexts self.switch_h5(contexts[0]) time.sleep(2) self.click_element(tranLocation.take_receive) el = self.find_element(tranLocation.transfer_diff_wizard) if el: self.click_element(tranLocation.diff_confirm_button) time.sleep(3) self.click_element(tranLocation.text_confirm_button) time.sleep(1) except: raise Exception('签收调拨单出现异常') self.click_element(basePage.menu_btn_layout) page_size = basePage.GetPageSize(self) basePage.swipe_up(self, page_size, 0.1, 0.80, 0.1, 0.10) self.click_element(basePage.logout) self.click_element(basePage.text_confirm)
def member_query(self, business, username, password, telphone, tag): ''' 搜索会员,会员画像,会员资料,历史订单,优惠券 ''' basePage.login(self, business, username, password) while True: update_info = self.find_element(basePage.update_text_info) time.sleep(2) if not update_info: break try: # 点击菜单 self.click_element(basePage.menu_btn_layout) time.sleep(2) # 进入会员中心 self.click_element(memLocation.menu_info) time.sleep(2) if self.find_element(memLocation.iterm): self.click_element(memLocation.text_confirm) # 输入会员手机号码 for num in telphone: self.driver.press_keycode(basePage.keycode[num]) # 搜索会员 self.click_element(memLocation.search_product_btn) time.sleep(5) if self.find_element(memLocation.iterm): self.click_element(memLocation.text_confirm) self.click_element(memLocation.radio_history) time.sleep(2) self.click_element(memLocation.coupon_layout) time.sleep(2) if self.find_element(memLocation.iterm): self.click_element(memLocation.text_confirm) self.click_element(memLocation.radio_pic) self.click_element(memLocation.addTagBtn) self.input_element(memLocation.custom_targs, tag) self.click_element(memLocation.add_targs_button) time.sleep(2) self.click_element(memLocation.confirm_button) time.sleep(2) # 验证标签是否添加成功 if self.find_element(memLocation.old_tag): print '会员标签添加成功' else: raise Exception('会员标签添加失败') self.click_element(memLocation.member_back) self.click_element(basePage.menu_btn_layout) sx = 0.1 sy = 0.25 ex = 0.1 ey = 0.75 basePage.swipe_up(self, basePage.GetPageSize(self), sx, sy, ex, ey) self.click_element(basePage.logout) self.click_element(basePage.text_confirm) except Exception as e: raise Exception('会员中心出现异常%s'%e)
def transfer_by_orderno(self, business, username, password, transferin_order, sku): ''' 调拨入库单高级搜索,根据调拨单号进行模糊搜索 :return: ''' # 登录 basePage.login(self, business, username, password) self.driver.wait_activity(".bash.ui.MainActivity", 10) while True: update_info = self.find_element(basePage.update_text_info) print update_info time.sleep(2) if update_info == False: break try: # 点击菜单 self.click_element(basePage.menu_btn_layout) # 向上滑到页面 page_size = basePage.GetPageSize(self) sx = 0.1 sy = 0.75 ex = 0.1 ey = 0.25 basePage.swipe_up(self, page_size, sx, sy, ex, ey) # 点击门店入库 self.click_element(tranLocation.stock_in) # 点击调拨入库 self.click_element(tranLocation.transfer_in) # 点击高级搜索 self.click_element(tranLocation.order_search) # 输入调拨单号 self.input_element(tranLocation.search_order_no, transferin_order) # 输入商品编码 self.input_element(tranLocation.search_order_sku, sku) # 点击调拨类型 self.click_element(tranLocation.type_edit) page_size = basePage.GetPageSize(self) sx = 0.5 sy = 0.75 ex = 0.5 ey = 0.80 basePage.swipe_up(self, page_size, sx, sy, ex, ey) self.click_element(tranLocation.transfer_options_submit) # 点击查询 self.click_element(tranLocation.search_query) self.click_element(basePage.menu_btn_layout) basePage.swipe_up(self, page_size, 0.1, 0.80, 0.1, 0.10) self.click_element(basePage.logout) self.click_element(basePage.text_confirm) except Exception as e: raise Exception('调拨入库单高级搜索出现异常:%s' % e)
def basic_reload_act(self, business, username, password, product_codes): basePage.login(self, business, username, password) self.driver.wait_activity(".bash.ui.MainActivity", 10) while True: update_info = self.find_element(basePage.update_text_info) time.sleep(2) if not update_info: break try: self.click_element(basePage.menu_btn_layout) page_size = basePage.GetPageSize(self) sx = 0.1 sy = 0.75 ex = 0.1 ey = 0.25 basePage.swipe_up(self, page_size, sx, sy, ex, ey) self.click_element(reLocation.module_item_name, timeout=1) # ===================>>>>>>>我的云单<<<<<<<<=============================== self.apply_reload(product_codes) self.click_element(reLocation.reload_state_choice, timeout=1) self.click_element(reLocation.draft_reload, timeout=1) self.click_element(reLocation.commit_reload_button, timeout=1) self.click_element(reLocation.conform_commit, timeout=3) self.click_element(reLocation.cancel_reload_button, timeout=3) self.click_element(reLocation.conform_commit, timeout=3) self.click_element(reLocation.reload_state_choice, timeout=1) self.click_element(reLocation.approve_reload, timeout=1) self.click_element(reLocation.reload_state_choice, timeout=1) self.click_element(reLocation.waiting_reload, timeout=1) self.click_element(reLocation.reload_state_choice, timeout=1) self.click_element(reLocation.done_reload, timeout=1) self.click_element(reLocation.reload_state_choice, timeout=1) self.click_element(reLocation.reject_reload, timeout=1) self.click_element(reLocation.commit_reload_button, timeout=1) self.click_element(reLocation.conform_commit, timeout=3) self.click_element(reLocation.cancel_reload_button, timeout=3) self.click_element(reLocation.conform_commit, timeout=3) self.click_element(reLocation.reload_state_choice, timeout=1) self.click_element(reLocation.cancel_reload, timeout=1) except Exception as e: raise Exception('报表查询操作出现异常')
def shop_inventory_diff(self, business, username, password): basePage.login(self, business, username, password) self.driver.wait_activity(".bash.ui.MainActivity", 10) while True: update_info = self.find_element(basePage.update_text_info) time.sleep(2) if update_info == False: break try: self.click_element(basePage.menu_btn_layout) self.click_element(reLocation.module_item_name, timeout=4) contexts = self.driver.contexts self.driver.switch_to.context(contexts[1]) time.sleep(4) self.click_element(reLocation.shop_inventory_diff_button, timeout=4) self.click_element(reLocation.report_search_button, timeout=6) except: raise Exception('报表查询操作出现异常')
def scrap_by_orderno(self, business, username, password, transferin_order, sku): ''' 调拨入库单高级搜索,根据调拨单号进行模糊搜索 :return: ''' # 登录 basePage.login(self, business, username, password) self.driver.wait_activity(".bash.ui.MainActivity", 10) while True: update_info = self.find_element(basePage.update_text_info) time.sleep(2) if not update_info: break try: # 点击菜单 self.click_element(basePage.menu_btn_layout) # 向上滑到页面 page_size = basePage.GetPageSize(self) sx = 0.1 sy = 0.75 ex = 0.1 ey = 0.25 basePage.swipe_up(self, page_size, sx, sy, ex, ey) # 点击库存损益 self.click_element(sLocation.scrap) # 点击高级搜索 self.click_element(sLocation.order_search) # 输入退货单号 self.input_element(sLocation.search_order_no, transferin_order) # 输入商品编码 self.input_element(sLocation.search_order_sku, sku) # 点击查询 self.click_element(sLocation.search_query) time.sleep(1) self.click_element(basePage.menu_btn_layout) time.sleep(2) basePage.swipe_up(self, page_size, 0.1, 0.80, 0.1, 0.10) self.click_element(basePage.logout) self.click_element(basePage.text_confirm) except Exception as e: raise Exception('损益单高级搜索出现异常:%s' % e)
def inventory_create(self, business, username, password, rack_name): ''' 创建盘点单 :return: ''' basePage.login(self, business, username, password) self.driver.wait_activity(".bash.ui.MainActivity", 10) while True: update_info = self.find_element(basePage.update_text_info) time.sleep(2) if not update_info: break self.click_element(basePage.menu_btn_layout) self.click_element(inLocation.module_item_name) processing = self.find_element(inLocation.inventory_details_cancel_btn) if processing: self.click_element(inLocation.inventory_details_cancel_btn) self.click_element(inLocation.stock_list_add_btn) self.click_element(inLocation.new_inventory_submit_btn) self.click_element(inLocation.add_rack) rack_names = random.randint(1, 999999) self.input_element(inLocation.rack_name, rack_names) self.click_element(inLocation.text_confirm)
def best_info(self, business, username, password, product_code): basePage.login(self, business, username, password) self.driver.wait_activity(".bash.ui.MainActivity", 10) while True: update_info = self.find_element(basePage.update_text_info) print update_info time.sleep(2) if not update_info: break try: self.click_element(basePage.menu_btn_layout) self.click_element(bsLocation.module_item_name) time.sleep(5) contexts = self.driver.contexts self.switch_h5(contexts[1]) time.sleep(4) self.click_element(bsLocation.search_product_btn) self.input_element(bsLocation.input_product, product_code) self.click_element(bsLocation.search) time.sleep(2) self.click_element(bsLocation.clear) self.click_element(bsLocation.cancel) el = self.find_element(bsLocation.favourite_product) if el: self.click_element(bsLocation.favourite_product) time.sleep(5) self.click_element(bsLocation.inventory) time.sleep(2) self.click_element(bsLocation.back_btn) contexts = self.driver.contexts self.switch_h5(contexts[0]) time.sleep(5) self.click_element(basePage.menu_btn_layout) page_size = basePage.GetPageSize(self) basePage.swipe_up(self, page_size, 0.1, 0.80, 0.1, 0.10) self.click_element(basePage.logout) self.click_element(basePage.text_confirm) except: raise Exception('畅销排行操作出现异常')
def basic_report_act(self, business, username, password): basePage.login(self, business, username, password) self.driver.wait_activity(".bash.ui.MainActivity", 10) while True: update_info = self.find_element(basePage.update_text_info) time.sleep(2) if not update_info: break try: self.click_element(basePage.menu_btn_layout) self.click_element(reLocation.module_item_name, timeout=4) contexts = self.driver.contexts self.driver.switch_to.context(contexts[1]) time.sleep(4) for x in reLocation.all_reports: self.click_element(x, timeout=4) self.click_element(reLocation.report_search_button, timeout=6) self.click_element(reLocation.menu_back_button, timeout=6) print x except Exception as e: print e raise Exception('报表查询操作出现异常')
def member_register(self, business, username, password, tag): ''' 注册会员,添加新会员标签 ''' basePage.login(self,business, username, password) while True: update_info = self.find_element(basePage.update_text_info) time.sleep(2) if not update_info: break try: # 点击菜单 self.click_element(basePage.menu_btn_layout) time.sleep(2) # 进入会员中心 self.click_element(memLocation.menu_info) time.sleep(2) if self.find_element(memLocation.iterm): self.click_element(memLocation.text_confirm) new_member = self.createPhone() for new_num in new_member: self.driver.press_keycode(basePage.keycode[new_num]) self.click_element(memLocation.add_member_txt) time.sleep(2) if self.find_element(memLocation.hint_text): self.click_element(memLocation.text_confirm) time.sleep(5) new_name = self.memberName().decode('utf-8') self.input_element(memLocation.register_name, new_name) self.click_element(random.choice(memLocation.sex)) self.click_element(memLocation.register_save) time.sleep(2) self.tag_info = self.tag_info % new_member if self.find_element(self.tag_info): self.click_element(memLocation.text_confirm) time.sleep(5) if self.find_element(memLocation.iterm): self.click_element(memLocation.text_confirm) self.click_element(memLocation.radio_pic) self.click_element(memLocation.addTagBtn) self.input_element(memLocation.custom_targs, tag) self.click_element(memLocation.add_targs_button) time.sleep(2) self.click_element(memLocation.confirm_button) time.sleep(2) # 验证标签是否添加成功 if self.find_element(memLocation.old_tag): print '会员标签添加成功' else: raise Exception('会员标签添加失败') time.sleep(2) # 使用新注册的会员进行下单 self.click_element(memLocation.sale_btn) try: self.find_element(memLocation.member_name.text == new_name) print '跳转到购物车页面成功带上会员' except: raise Exception('异常') self.click_element(basePage.menu_btn_layout) sx = 0.1 sy = 0.25 ex = 0.1 ey = 0.75 basePage.swipe_up(self, basePage.GetPageSize(self), sx, sy, ex, ey) self.click_element(basePage.logout) self.click_element(basePage.text_confirm) except Exception as e: raise Exception('会员中心添加标签出现异常%s'%e)
def sale_test(self, business, username, password, product_code, telphone): basePage.login(self, business, username, password) self.driver.wait_activity(".bash.ui.MainActivity", 10) while True: update_info = self.find_element(basePage.update_text_info) print update_info time.sleep(2) if update_info == False: break try: # 输入商品编码 for i in product_code: self.driver.press_keycode(basePage.keycode[i]) self.click_element(basePage.keypad_search_btn) self.click_element(scLocation.product_sizes[0]) self.click_element(scLocation.product_colors[0]) self.click_element(scLocation.confirm_txt) # 清空购物车 self.click_element(scLocation.shopcar_clear_btn) # 确认清空操作 self.click_element(scLocation.text_confirm) # 商品的颜色和尺码生成唯一的组合 datagroup = [scLocation.product_colors, scLocation.product_sizes] cartesian = basePage.Cartesian(datagroup) attrlist = cartesian.assemble() for info in attrlist: # 输入商品编码 for i in product_code: self.driver.press_keycode(basePage.keycode[i]) self.click_element(basePage.keypad_search_btn) color_info = info[0] size_info = info[1] self.click_element(size_info) self.click_element(color_info) self.click_element(scLocation.confirm_txt) # 输入会员手机号码 for num in telphone: self.driver.press_keycode(basePage.keycode[num]) self.click_element(basePage.keypad_search_btn) # 选择销售员 self.click_element(scLocation.saleman_text) self.click_element(scLocation.tv_sale_name) self.click_element(scLocation.tv_confirm) # 点击下一步 self.click_element(scLocation.settle_btn) # 确认提示信息 if self.find_element(scLocation.text_confirm): self.click_element(scLocation.text_confirm) try: # 检查是否进入选择促销的页面 self.find_element(scLocation.member_promotion_name) # 点击去支付 self.click_element(scLocation.settle_btn) except: raise Exception('上传销售订单出现异常') # 选择现金支付 self.click_element(scLocation.pay_cash) # 确认支付 self.click_element(scLocation.confirm_pay) try: # 检查是否支付成功 self.find_element(scLocation.img_gou) # 开始新订单 self.click_element(scLocation.text_restart) print '支付成功' except: raise Exception('支付出现异常') self.click_element(basePage.menu_btn_layout) page_size = basePage.GetPageSize(self) basePage.swipe_up(self, page_size, 0.1, 0.80, 0.1, 0.10) self.click_element(basePage.logout) self.click_element(basePage.text_confirm) except Exception as e: raise Exception('创建销售订单出现异常:%s' % e)
def transfer_out_upload(self, business, username, password, product_codes): basePage.login(self, business, username, password) self.driver.wait_activity(".bash.ui.MainActivity", 10) while True: update_info = self.find_element(basePage.update_text_info) time.sleep(2) if not update_info: break try: # 点击菜单 self.click_element(basePage.menu_btn_layout) # 向上滑到页面 page_size = basePage.GetPageSize(self) sx = 0.1 sy = 0.75 ex = 0.1 ey = 0.25 basePage.swipe_up(self, page_size, sx, sy, ex, ey) # 点击门店出库 self.click_element(tranLocation.stock_out) # 点击调拨出库 self.click_element(tranLocation.transfer_out) time.sleep(5) self.click_element(tranLocation.title) self.click_element(tranLocation.draft_order) self.click_element(tranLocation.confirm_allocate_txt) el = self.find_element(tranLocation.confirm_tip) if el: self.click_element(tranLocation.text_confirm) self.click_element(tranLocation.details_text) contexts = self.driver.contexts self.switch_h5(contexts[1]) time.sleep(7) self.click_element(tranLocation.add_handle) time.sleep(4) for code in product_codes: contexts = self.driver.contexts self.switch_h5(contexts[0]) time.sleep(7) self.click_element(tranLocation.search_product) for num in code: self.driver.press_keycode(basePage.keycode[num]) self.click_element(basePage.keypad_search_btn) contexts = self.driver.contexts self.switch_h5(contexts[1]) time.sleep(4) self.click_element(tranLocation.product_colors) self.click_element(tranLocation.product_size) self.click_element(tranLocation.add) self.click_element(tranLocation.back_btn) self.click_element(tranLocation.confirm) self.click_element(tranLocation.back_btn) time.sleep(1) contexts = self.driver.contexts self.switch_h5(contexts[0]) time.sleep(6) self.click_element(tranLocation.confirm_allocate_txt) self.click_element(tranLocation.allocate_next) time.sleep(1) self.click_element(tranLocation.allocate_next) time.sleep(2) self.click_element(basePage.menu_btn_layout) page_size = basePage.GetPageSize(self) basePage.swipe_up(self, page_size, 0.1, 0.80, 0.1, 0.10) self.click_element(basePage.logout) self.click_element(basePage.text_confirm) else: self.click_element(tranLocation.text_confirm) self.click_element(tranLocation.allocate_next) time.sleep(1) self.click_element(tranLocation.allocate_next) time.sleep(2) self.click_element(basePage.menu_btn_layout) page_size = basePage.GetPageSize(self) basePage.swipe_up(self, page_size, 0.1, 0.80, 0.1, 0.10) self.click_element(basePage.logout) self.click_element(basePage.text_confirm) except Exception as e: raise Exception('提交调拨出库出现异常%s' % e)