def linkmanInfo(self, lnumber): #for循环得到“家庭联系人”,“紧急联系人” for i in range(lnumber): #点“新建”按钮弹出“联系人-新增”页面 self.driver.find_element_by_xpath( "//*[@id='contact_info']/div/a[text()='新建']").click() time.sleep(3) if i == 0: #联系类型,“家庭联系人” Select(self.driver.find_element_by_id( "dtocontactType")).select_by_value("3") #和本人关系,母亲 Select(self.driver.find_element_by_id( "dtoconRelation")).select_by_value("4") else: # 联系类型,“紧急联系人” Select(self.driver.find_element_by_id( "dtocontactType")).select_by_value("2") # 和本人关系,配偶 Select(self.driver.find_element_by_id( "dtoconRelation")).select_by_value("2") #姓名 conName = getFullName() self.driver.find_element_by_id("dtoconName").send_keys(conName) #联系电话 conPhone = createPhone() self.driver.find_element_by_id("dtoconPhone").send_keys(conPhone) #点“确定”按钮 self.driver.find_element_by_xpath("//span[text()='确定']").click()
def test_body(self): req.httpname = "KPTEST" self.url = get_excel("url", self.No, interfaceNo) # flag为1时,则重新生成新手机号;flag为2时,则从excel中读取已存在的 self.flag = get_excel("flag", self.No, interfaceNo) # 根据flag进行判断,手机号是否生成新手机号 if (self.flag == "1"): # 重新生成新手机号 self.telphone = createPhone() else: # 从excel中获取手机号 self.telphone = get_excel("mobile", self.No, interfaceNo) # 获取姓名 self.nick = getFullName() # 注册密码 self.password = get_excel("password", self.No, interfaceNo) # 注册类型 1=普通密码注册 2=短信验证码 self.regtype = get_excel("regtype", self.No, interfaceNo) # 国家编码,86中国,其他国外 self.countrycode = get_excel("countrycode", self.No, interfaceNo) # 获取验证码的方法 self.veresult = getSendverify(self.logger, "reg", "mobile", self.telphone, self.countrycode) if self.veresult == 0: time.sleep(10) # 从数据库中查询验证码 self.verifycode = query_sql(self.logger, self.telphone, self.countrycode) # 根据注册类型判断是输入验证码或密码 print("用户注册接口手机号==" + self.telphone) self.data = { "mobile": self.telphone, "nick": self.nick, "reg_type": self.regtype, "verify": self.verifycode, "pass": self.password, "source": "1", "country_code": self.countrycode, "yk_token": "5", "app_version": "8.0.0", "system": "3", "device_model": "HUAWEI P10", "system_version": "V1.0.0", "channel": "5" } print(self.data) req.set_url(self.url) req.set_data(self.data) self.response = req.post() try: self.retcode = self.response["code"] except Exception: self.logger.error("报文返回为空!") print("报文返回为空!") self.check_result() self.wr_excel()
def test_body(self): req.httpname = "KPTEST" self.url = get_excel("url", self.No, interfaceNo) # 国家编码 self.countrycode = get_excel("countrycode", self.No, interfaceNo) # flag为1时,则重新生成新手机号;flag为2时,则从excel中读取已存在的 self.flag = get_excel("flag", self.No, interfaceNo) # 根据flag进行判断,手机号是否生成新手机号 if (self.flag == "1"): # 重新生成新手机号 self.telphone = createPhone() else: # 从excel中获取手机号 self.telphone = get_excel("mobile", self.No, interfaceNo) # 密码 self.password = get_excel("password", self.No, interfaceNo) # 获取登录sheet页中token self.token = get_excel("token", self.No, "login") # 获取验证码的方法 getSendverify(self.logger, "reg", "mobile", self.telphone, self.countrycode) time.sleep(10) # 从数据库中查询验证码 self.verifycode = query_sql(self.logger, self.telphone, self.countrycode) self.data = { "country_code": self.countrycode, "mobile": self.telphone, "verify": self.verifycode, "pass": self.password, "system": "5", "device_model": "HUAWEI P10", "system_version": "V1.0.0", "channel": "5" } print(self.data) if self.token == "": self.urlq = self.url self.logger.info(interfaceNo + ">>>>token为空=====" + self.urlq) else: self.urlq = self.url + "&&token=" + self.token self.logger.info(interfaceNo + ">>>>token=====" + self.urlq) req.set_url(self.urlq) req.set_data(self.data) self.response = req.post() print(self.response) try: self.retcode = self.response["code"] except Exception: self.logger.error("报文返回为空!") print("报文返回为空!") self.check_result() self.wr_excel()
def addincom(self): try: ''' 客户借款需求,implicitly_wait() 方法可以方便的实现智能等待 ''' time.sleep(5) # 家人是否知晓 Select(self.driver.find_element_by_id( "dtofamilyIsKnown")).select_by_value("1") # 借款用途 Select(self.driver.find_element_by_id( "dtoloanPrePurpose")).select_by_value("102") time.sleep(1) Select(self.driver.find_element_by_id( "dtoloanPurpose")).select_by_value("13") # 申请借款金额 self.driver.find_element_by_id("dtominAppAmount").send_keys( "100000") # 月还款能力 self.driver.find_element_by_id("dtomonthPayment").send_keys( "10000") # 申请期限 Select(self.driver.find_element_by_id( "dtoapplyPeriod")).select_by_value("36") # 申请渠道 Select(self.driver.find_element_by_id( "dtocustomerChannel")).select_by_value("0") ''' 客户基本信息 ''' # 民族 self.driver.find_element_by_id("dtonation").send_keys("汉族") # 户籍详细地址 Select(self.driver.find_element_by_id( "phometownAreacode")).select_by_value("110000") Select(self.driver.find_element_by_id( "chometownAreacode")).select_by_value("110100") Select(self.driver.find_element_by_id( "dtohometownAreacode")).select_by_value("110101") self.driver.find_element_by_id("dtohometownAddr").send_keys( "北京市东城区银河SOHOD座") # 最高学历,选中“本科” Select(self.driver.find_element_by_id( "dtohDegree")).select_by_value("2") # 婚姻状态,选中已婚 Select(self.driver.find_element_by_id( "dtomarrStatus")).select_by_value("2") # 有无子女 Select(self.driver.find_element_by_id( "dtohasChild")).select_by_value("0") # 您来本市的年份 self.driver.find_element_by_id("dtoinCityYear").send_keys("2009") # 移动电话 phone = createPhone() self.driver.find_element_by_id("dtomobilePhone").send_keys(phone) # 有无住宅电话 Select(self.driver.find_element_by_id( "dtohasTelephone")).select_by_value("0") # 电子邮件 self.driver.find_element_by_id("dtoemail").send_keys(phone + "@139.com") # 现住址 Select(self.driver.find_element_by_id( "pcurrentAreacode")).select_by_value("110000") Select(self.driver.find_element_by_id( "ccurrentAreacode")).select_by_value("110100") Select(self.driver.find_element_by_id( "dtocurrentAreacode")).select_by_value("110102") self.driver.find_element_by_id("dtocurrentAddr").send_keys( "北京市西城区西四胡同") # 住宅类型 Select(self.driver.find_element_by_id( "dtohomeType")).select_by_value("1") # 税后月均总收入(元) self.driver.find_element_by_id( "dtoafterTaxMonthlyIncome").send_keys("20000") # 客户来源 Select(self.driver.find_element_by_id( "dtocustomerSource")).select_by_value("9") # 调用“个人授权信息,上传文件”方法 self.uploadfile() # 调用“客户工作信息”方法 self.customerInfo() # 调用“联系人信息”方法 self.linkmanInfo(2) # 调用“银行卡信息”方法 self.bankcardInfo(phone) # 调用“流水负债信息”方法 self.incurdebtsInfo() time.sleep(3) # 保存 self.driver.find_element_by_id("doAddInto").click() except Exception as err: logger.error(err)