def new_customer(self, flag=None): """新增客户""" logging.info(format_str('new_customer')) self.click(CUSTOMER['新增客户']) sleep(0.5) subname = ['小店', '副食', '酒楼', '批发', '烟酒', '便利店', '小卖部', '超市', '百货'] customer_name = create_name() + random.choice(subname) self.clear_and_sendkeys(CUSTOMER['客户名'], customer_name) self.clear_and_sendkeys(CUSTOMER['联系人'], create_name()) self.clear_and_sendkeys(CUSTOMER['电话'], create_phone()) self.click(CUSTOMER['客户类型']) sleep(0.5) subtype = ['零售终端', '批发', '餐饮', '其他', '商超'] types = self.find_elements(CUSTOMER['列表']) while True: t = random.choice(types) if t.text in subtype: t.click() break sleep(0.5) self.click(CUSTOMER['客户等级']) sleep(0.5) rank = self.find_elements(CUSTOMER['列表']) random.choice(rank).click() # 选择配送地址 self.click(CUSTOMER['省市区']) self.switch_to_native() # 切换到APP视图做swipe操作,滑动选择省市区 width = self.driver.get_window_size().get('width') # 获取屏幕宽度 height = self.driver.get_window_size().get('height') # 获取屏幕高度 self.driver.swipe(width * 0.25, height * 0.9, width * 0.25, height * 0.1) self.driver.swipe(width * 0.9, height * 0.9, width * 0.9, height * 0.7) self.switch_to_webview() # 切换到H5视图继续后面的操作 self.click(CUSTOMER['完成']) self.clear_and_sendkeys(CUSTOMER['详细地址'], create_gbk(8)) if flag: for _ in range(random.randint(1, 3)): self.click(CUSTOMER['添加图片']) self.switch_to_native() # 切换到微信视图控制相机拍照 self.click(PUBLIC['拍照']) self.click(PUBLIC['确认照片']) sleep(3) # 等待图片上传完成 self.switch_to_webview() # 切换到H5视图继续操作 self.click(CUSTOMER['新增']) sleep(0.5) self.click(CUSTOMER['确定']) sleep(1)
def customer_visit_replenish(self, flag=None): """常规拜访-补录""" logging.info(format_str('customer_visit_replenish')) self.click(CUSTOMER['拜访补录']) self.clear_and_sendkeys(CUSTOMER['备注'], create_gbk(30)) # 添加备注信息 self.upload_photo(flag) # 添加照片 self.click(CUSTOMER['提交']) sleep(1) self.click(CUSTOMER['确定']) self.click(CUSTOMER['拜访完成']) self.click(CUSTOMER['确定'])
def customer_visit(self, flag=None): """常规拜访""" logging.info(format_str('customer_visit')) self.click(CUSTOMER['常规拜访']) self.clear_and_sendkeys(CUSTOMER['备注'], create_gbk(30)) self.take_photo(flag) self.click(CUSTOMER['提交']) sleep(1) self.click(CUSTOMER['确定']) self.click(CUSTOMER['拜访完成']) self.click(CUSTOMER['确定'])
def groupon_activity(self, flag=None): """团购直销活动""" # 进入团购直销活动 self.choose_activity_type(1) logging.info(format_str('groupon_activity')) self.choose_activity() # 选择活动 self.choose_expense() # 选择费用明细 self.clear_and_sendkeys(ACTIVITY['单位名称'], create_gbk(5)) self.clear_and_sendkeys(ACTIVITY['联系人'], create_name()) self.clear_and_sendkeys(ACTIVITY['电话'], create_phone()) self.present_num() # 赠送数量 self.present_money() # 赠送金额 self.take_photo(flag) # 拍照上传 self.submit_and_confirm()
def cultivate_activity_supplement(self, flag=None): """消费培育活动-补录""" # 选择消费培育活动 self.choose_activity_supplement_type(0) logging.info(format_str('cultivate_activity_supplement')) self.choose_activity() # 选择活动 self.choose_expense() # 选择费用明细 self.clear_and_sendkeys(ACTIVITY['联系人'], create_name()) self.clear_and_sendkeys(ACTIVITY['电话'], create_phone()) self.clear_and_sendkeys(ACTIVITY['地址'], create_gbk(6)) self.clear_and_sendkeys(ACTIVITY['人数'], random.randint(1, 3)) self.present_num() # 赠送数量 self.present_money() # 赠送金额 self.upload_photo(flag) # 上传照片 self.submit_and_confirm() sleep(2)
def activity_audit(self, flag=None): """ 活动审核 :param flag: True代表审核通过,False代表审核拒绝 """ self.click(AUDIT['活动审核']) if not self.is_exists(AUDIT['拒绝']): logging.warning('{:*^56}'.format(' 活动审核列表为空 ')) return if flag: self.audit_pass() else: logging.info(format_str('audit_refuse')) self.click(AUDIT['拒绝']) self.clear_and_sendkeys(AUDIT['备注'], create_gbk(10)) self.click(AUDIT['确认']) self.return_index()
def visit_audit(self, flag=True): """ 客户拜访审核 :param flag: True代表审核通过,False代表审核拒绝 """ self.click(AUDIT['拜访审核']) if not self.is_exists(AUDIT['拒绝']): logging.warning('{:*^56}'.format(' 拜访审核列表为空 ')) return if flag: self.audit_pass() else: logging.info(format_str('audit_refuse')) self.click(AUDIT['拒绝']) sel = self.find_element(AUDIT['拜访拒绝理由']) Select(sel).select_by_value(str(random.randint(1, 3))) self.clear_and_sendkeys(AUDIT['备注'], create_gbk(10)) self.click(AUDIT['确认']) self.return_index()
def feast_activity(self, flag=None): """宴席推广活动""" # 进入宴席推广活动 self.choose_activity_type(2) logging.info(format_str('feast_activity')) # 选择宴席类型 self.click(ACTIVITY['宴席类型']) sleep(1) banquets = self.find_elements(ACTIVITY['列表']) random.choice(banquets).click() sleep(0.5) self.choose_activity() # 选择活动 self.choose_expense() # 选择费用明细 self.clear_and_sendkeys(ACTIVITY['联系人'], create_name()) self.clear_and_sendkeys(ACTIVITY['电话'], create_phone()) self.clear_and_sendkeys(ACTIVITY['地址'], create_gbk(6)) self.clear_and_sendkeys(ACTIVITY['人数'], random.randint(1, 3)) self.present_num() # 赠送数量 self.present_money() # 赠送金额 self.take_photo(flag) # 上传照片 self.submit_and_confirm()