def gongDan(self): time.sleep(random.randint(1, 3)) markPath = getConstant.PROJECT_PATH + "/common/numberMark.txt" mark = writeAndReadTextFile().test_read_txt(markPath) dict_mark = json.loads(mark) number = int(dict_mark['sm_sb']) + 1 orderData = self.loginItems['sm']['result'] orderData['longitude'] = '14090823.883200558' orderData['latitude'] = '5446737.409308622' orderData['complaincontent'] = '流程二,设施脏污' + str(number) #描述 orderData['bgcode'] = '220202003001' #网格 orderData['bgcodename'] = '锦东社区' #地址 orderData['gridid'] = '220202003001' orderData['wxsource'] = 'GZHJB' orderData[ 'imgurl'] = '/image/20181008/f7bffd2e16154c8f817f5fc1b442f21d.jpg' orderData['eorcid'] = getConstant.EORCID_SJ orderData['eventoneid'] = getConstant.SJ_SGGL orderData['eventtwoid'] = getConstant.SJ_SGGL_WZJL res = submitOrder(orderData).test_app_sm_submitOrder() if res: dict_mark["sm_sb"] = str(number) writeAndReadTextFile().test_write_txt(markPath, json.dumps(dict_mark)) logging.info("*****3.市民上报案卷完毕*****") return {'description': number}
def gongDan(self): time.sleep(random.randint(1, 3)) markPath = getConstant.PROJECT_PATH + "/common/numberMark.txt" mark = writeAndReadTextFile().test_read_txt(markPath) dict_mark = json.loads(mark) number = int(dict_mark['zfj_sb']) + 1 orderData = self.loginItems['zfj']['user'] orderData['eorcid'] = getConstant.EORCID_SJ #事部件类型 orderData['fieldintro'] = '吉林市 经济开发区 工厂 鑫海实业 ' orderData['mposl'] = '14077292.84373848' orderData['description'] = "流程四,经开区道路不干净,环境脏乱差" + str(number) orderData['eventtypeoneId'] = getConstant.SJ_JMZX #大类 街面秩序 orderData['gridid'] = '220298205118' # orderData['bgadminId'] = #上报人id orderData['eventtypetwoId'] = getConstant.SJ_JMZX_LDLF #小类 乱堆乱放 orderData['mposb'] = '5459844.618760589' sb_picpath1 = "E:/test/dcms/ChengGuan/testFile/img/26.png" sb_picpath2 = "E:/test/dcms/ChengGuan/testFile/img/27.png" orderData['imgPath'] = [sb_picpath1, sb_picpath2] res = submitOrder(orderData).test_app_submitOrder() if res: dict_mark["zfj_sb"] = str(number) writeAndReadTextFile().test_write_txt(markPath, json.dumps(dict_mark)) logging.info("*****3.%s上报案卷完毕*****" % orderData['name']) else: logging.info("XXXXXXXXXX3.%s执法局上报案卷失败XXXXXXXXXX" % orderData['name'])
def setUpClass(cls): #放对数据可操作的代码,如对mysql、momgodb的初始化等,这里不对数据库进行操作! # cls.driver = webdriver.Chrome("D:/python/chromeDriverSever/chromedriver.exe") # logging.info("***打开浏览器***") # # 初始化登录数据及登录类对象 # userData = {} # if '180' in getConstant.IP: # ip = getConstant.IP+getConstant.PORT_7897 # userData = { # 'sm':{'loginName':'13161577834','password':'******'}, # 'wggly':{'role':'2','logonname':'csgly','logonpassword':'******'}, # 'qsdw':{'role':'6','logonname':'cshbj','logonpassword':'******'}, # 'zfj':{'role':'5','logonname':'cszfj','logonpassword':'******'}, # } # else: # ip = getConstant.IP # userData = { # 'sm':{'loginName':'13161577834','password':'******'}, # 'wggly':{'role':'2','logonname':'gly','logonpassword':'******'}, # 'qsdw':{'role':'6','logonname':'hbj','logonpassword':'******'}, # 'zfj':{'role':'5','logonname':'zfj','logonpassword':'******'}, # } # url= ip+'/dcms/bms/login.jsp' # print("url:",url) # cls.loginObj = allLogin(cls.driver,url,userData) # 初始化移动端登录人员集合对象 cls.loginItems = writeAndReadTextFile().test_read_appLoginResult() #获取cookies cls.cookies = writeAndReadTextFile().test_readCookies()
def __init__(self,condition): self.condition = condition if '180' in getConstant.IP: self.ip = getConstant.IP+getConstant.PORT_7897 elif '91' in getConstant.IP: self.ip = getConstant.IP else: print("正式库不允许删除案卷!!!") self.ip = getConstant.IP+getConstant.PORT_7897 self.gjxtId = writeAndReadTextFile().test_read_systemId('构建系统') self.header = {"Cookie":writeAndReadTextFile().test_readCookies()}
def __init__(self,dataItem): self.dataItem = dataItem if '180' in getConstant.IP: self.ip = getConstant.IP+getConstant.PORT_7897 else: self.ip = getConstant.IP self.keywords = writeAndReadTextFile().test_read_systemId('协调系统') self.header = { "User-Agent":"Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36", "Accept":"text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8", "Accept-Encoding":"gzip, deflate", "Accept-Language":"zh-CN,zh;q=0.9,en;q=0.8", "Cookie":writeAndReadTextFile().test_readCookies() }
def test_app_allLogin(self): sm = self.test_app_sm_login() # sm = 'sm' zfj = self.test_app_zfj_login() qsdw = self.test_app_qsdw_login() wggly = self.test_app_wggly_login() if sm and zfj and qsdw and wggly: loginObj = {"sm": sm, "zfj": zfj, "qsdw": qsdw, "wggly": wggly} path = "E:/test/dcms/ChengGuan/common/appLoginResult.txt" writeAndReadTextFile().test_write_txt(path, str(loginObj)) print("移动端:*apk登录成功") return True else: self.test_app_allLogin()
def BatchUpload(self): # allXQDurl = self.ip+"/partselection/poilyrs/getListSanjiByPage.do?curPage=1&pageSize=10000&_="+str(round(time.time()*1000)) # allres = requests.get(allXQDurl,headers = self.header,timeout = 20) # if allres.status_code == 200: # AllRES = json.loads(allres.text) # arrres = [] # for item in AllRES['result']['list']: # arrres.append(item['classid3']) # strres = ','.join(arrres) # writeAndReadTextFile().test_write_txt('E:/UI/xqd.txt',strres) # print(item['classid3']) weiYiMa_arr = writeAndReadTextFile().test_read_txt('E:/UI/xqd.txt') weiYiMaArr = [] weiYiMaArr = weiYiMa_arr.split(',') for weiYiMa in weiYiMaArr: ######### oneid = weiYiMa[0:2] ######### twoid = weiYiMa[2:4] ######### threeid = weiYiMa[4:6] time.sleep(5) # print("888",weiYiMa) threeItem = self.XQDdetails(weiYiMa) # print(threeItem) time.sleep(2) self.XQDDetailsAndUpdeit(threeItem[0])
def gongDan(self): """ pc端工单录入 """ time.sleep(random.randint(2, 4)) markPath = getConstant.PROJECT_PATH + "/common/numberMark.txt" mark = writeAndReadTextFile().test_read_txt(markPath) dict_mark = json.loads(mark) number = int(dict_mark['web_sb']) + 1 orderData = {} userItem = self.loginItems['wggly'] #网格管理员 picpath = "E:/test/dcms/ChengGuan/testFile/img/1.png" img_value = ('1.png', open(picpath, 'rb'), 'multipart/form-data') orderData['mposl'] = '14088659.985423975' orderData['mposb'] = '5442040.762812978' orderData['menuId'] = '402880822f9490ad012f949eb313008a' orderData['isFh'] = '1' orderData['street'] = '220204002' orderData['p_name'] = '董楚楚' orderData['p_sex'] = '女' orderData['p_job'] = '教师' orderData['p_phone'] = '0102864987' orderData['other_phone'] = '15866993322' orderData['feedback'] = '手机' orderData['source'] = '402880822f47692b012f4774e5710010' #案卷来源 orderData['eorc'] = getConstant.EORCID_SJ #案卷类型 orderData['eventtypeone'] = getConstant.SJ_XCGG #事件大类 orderData['eventtypetwo'] = getConstant.SJ_XCGG_FFXGG #小类 orderData['regioncode'] = '220204' orderData['bgcode'] = '220204002' orderData['bgadminid'] = userItem['user']['id'] orderData['bgadminid2'] = userItem['user']['name'] orderData['gridid'] = '220204002003' orderData['needconfirm'] = '0' orderData['description'] = '流程一,非法小广告' + str(number) orderData['dealWay'] = 'on' orderData['fieldintro'] = '吉林市 船营区 南京街道 怀德社区' orderData['upload'] = img_value gdlr_res = submitOrder(orderData).test_web_submitOrder() if gdlr_res: dict_mark["web_sb"] = str(number) writeAndReadTextFile().test_write_txt(markPath, json.dumps(dict_mark)) logging.info("3.web工单录入完毕") return {'description': number, 'userId': userItem['user']['id']}
def setUpClass(cls): #放对数据可操作的代码,如对mysql、momgodb的初始化等,这里不对数据库进行操作! # cls.driver = webdriver.Chrome("D:/python/chromeDriverSever/chromedriver.exe") chrome_options = webdriver.ChromeOptions() chrome_options.add_argument('--headless') cls.driver = webdriver.Chrome(chrome_options=chrome_options) # cls.driver = webdriver.ChromeOptions() # cls.driver = webdriver.PhantomJS(executable_path="D:/python/chromeDriverSever/phantomjs-2.1.1-windows/bin/phantomjs.exe") logging.info("***打开浏览器***") # 初始化登录数据及登录类对象 userData = {} if '180' in getConstant.IP: ip = getConstant.IP+getConstant.PORT_7897 userData = { 'sm':{'loginName':'13161577834','password':'******'}, 'wggly':{'role':'2','logonname':'csgly','logonpassword':'******'}, 'qsdw':{'role':'6','logonname':'cshbj','logonpassword':'******'}, 'zfj':{'role':'5','logonname':'cszfj','logonpassword':'******'}, } elif '91' in getConstant.IP: ip = getConstant.IP userData = { 'sm':{'loginName':'13161577834','password':'******'}, 'wggly':{'role':'2','logonname':'glyld','logonpassword':'******'}, 'qsdw':{'role':'6','logonname':'hbjld','logonpassword':'******'}, 'zfj':{'role':'5','logonname':'zfjld','logonpassword':'******'}, } else: ip = getConstant.IP userData = { 'sm':{'loginName':'13161577834','password':'******'}, 'wggly':{'role':'2','logonname':'glyld','logonpassword':'******'}, 'qsdw':{'role':'6','logonname':'hbjld','logonpassword':'******'}, 'zfj':{'role':'5','logonname':'zfjld','logonpassword':'******'}, } url= ip+'/dcms/bms/login.jsp' print("url:",url) cls.loginObj = allLogin(cls.driver,url,userData) # 初始化移动端登录人员集合对象 cls.loginItems = writeAndReadTextFile().test_read_appLoginResult() #获取cookies cls.cookies = writeAndReadTextFile().test_readCookies()
def test_liucheng(self): # 来源统计 self.laiYuanTongJi() # 综合查询 loginItems = writeAndReadTextFile().test_read_appLoginResult() loginItems['markNum'] = [2, 1] colligateQuery(loginItems).test_web_zongHeDetail() #综合查询列表》案件详情 colligateQuery(loginItems).test_ExportThisPage() #导出
def test_liucheng(self): webLogin = self.loginObj.test_web_login() apkLogin = self.loginObj.test_app_allLogin() if webLogin and apkLogin: loginItems = writeAndReadTextFile().test_read_appLoginResult() loginItems['markNum'] = [2,1] colligateQuery(loginItems).test_web_zongHeDetail() #综合查询列表》案卷详情 else: time.sleep(905) self.test_liucheng()
def newPersonnel(self, obj): if '180' in getConstant.IP: ip = getConstant.IP + getConstant.PORT_7897 else: ip = getConstant.IP url = ip + '/dcms/bmsAdmin/Admin-save.action' if 'zxcode' in obj: zxcode = obj['zxcode'] else: zxcode = "" if 'zxphone' in obj: zxphone = obj['zxphone'] else: zxphone = "" data = { "tempJumpUrl": "", "id": "", "groups": "", "logonpassword": "", "deptId": obj['deptId'], "bgids": "", "bgnms": "", "name": obj['name'], "logonname": obj['logonname'], "password": obj['password'], "position": obj['position'], "phone": obj['phone'], "mobilephone": obj['mobilephone'], "mac": "", "num": obj['num'], "deptname": obj['deptname'], "jobposition": obj['jobposition'], "lead": "", "activation": obj['activation'], "zxcode": zxcode, "zxphone": zxphone, "eno": obj['eno'], "file": "", "bgName": "", "groupnames": "", } header = {"Cookie": writeAndReadTextFile().test_readCookies()} r = requests.post(url=url, data=data, headers=header, allow_redirects=False) # print("返回值:",r.text) if ('Set-Cookie' in r.headers): print("请您先登录") elif '用户名已经存在' in r.text: print("返回结果", r.text) else: print("返回结果", r.text)
def __init__(self): # self.oderNumber = oderNumber if '180' in getConstant.IP: self.ip = getConstant.IP + getConstant.PORT_7897 else: self.ip = getConstant.IP self.header = { "User-Agent": "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36", "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8", "Accept-Encoding": "gzip, deflate", "Accept-Language": "zh-CN,zh;q=0.9,en;q=0.8", "Cookie": writeAndReadTextFile().test_readCookies() } self.keywords = writeAndReadTextFile().test_read_systemId('呼叫系统') # 初始化移动端登录人员集合对象 self.loginItems = writeAndReadTextFile().test_read_appLoginResult() #获取cookies self.cookies = writeAndReadTextFile().test_readCookies()
def __init__(self, ): # self.itemData = itemData if '180' in getConstant.IP: self.ip = getConstant.IP + getConstant.PORT_7884 else: self.ip = getConstant.IP self.header = { "Cookie": writeAndReadTextFile().test_readCookies(), "User-Agent": "Chrome/69.0.3497.100", 'Accept-Language': 'zh-CN,zh;q=0.9' } self.timeout = 20
def test_3gongDan_lc5(self): time.sleep(random.randint(1, 3)) markPath = getConstant.PROJECT_PATH + "/common/numberMark.txt" mark = writeAndReadTextFile().test_read_txt(markPath) dict_mark = json.loads(mark) number = int(dict_mark['zfj_sb']) + 1 orderData = self.loginItems['zfj']['user'] orderData['fieldintro'] = '吉林市 市管主街路 越山路 越山路 越山路(沙河子广场-解放中路)' orderData['gridid'] = '22029904000101' orderData['description'] = '流程五,建筑垃圾,渣土管理' + str(number) orderData['mposl'] = '14086190.785638873' orderData['mposb'] = '5441341.7074305825' res = submitOrder(orderData).test_app_reportInspection() if res: dict_mark["zfj_sb"] = str(number) writeAndReadTextFile().test_write_txt(markPath, json.dumps(dict_mark)) logging.info("*****3.%s上报案卷完毕*****" % orderData['name']) else: logging.info("XXXXXXXXXX3.执法局%s上报案卷失败XXXXXXXXXX" % orderData['name'])
def test_web_login(self): #登录的方法 authCode = test_login_authCode(self.driver, self.url) #获取验证码 while authCode == "": authCode = test_login_authCode(self.driver, self.url) else: self.driver.find_element_by_name('logonname').click() self.driver.find_element_by_name('logonname').send_keys( 'wangnannan') time.sleep(1) self.driver.find_element_by_name('logonpassword').click() self.driver.find_element_by_name('logonpassword').send_keys( '123456') time.sleep(1) self.driver.find_element_by_name('code').click() self.driver.find_element_by_name('code').send_keys(authCode) time.sleep(1) self.driver.find_element_by_xpath( '//*[@id="logonForm"]/p/input').click() if "智慧化城市管理云平台" in self.driver.page_source: loginResult = BeautifulSoup(self.driver.page_source, 'html.parser') input = loginResult.find('input', attrs={'id': 'sysMenu'}) #获取了input中的value属性值 inputvalue = input['value'] lginpath = 'E:/test/dcms/ChengGuan/common/webLoginResult.txt' writeAndReadTextFile().test_write_txt(lginpath, inputvalue) cookiestr = writeAndReadTextFile().test_getCookie(self.driver) print("cookies:", cookiestr) # 把cookie写入txt文件 cook_path = "E:/test/dcms/ChengGuan/common/cookie.txt" writeAndReadTextFile().test_write_txt(cook_path, cookiestr) print("web登录成功") return True else: print("web登录失败,用户名密码或验证码错误") # return False self.test_web_login()
def __init__(self,loginItems): self.loginItems = loginItems if '180' in getConstant.IP: self.ip = getConstant.IP+getConstant.PORT_7897 else: self.ip = getConstant.IP self.menuId = '4028838358b7f73b0158b9e7f3480c59' self.keywords = '402880ea2f6bd924012f6c521e8c0034' self.header = { "Cookie":writeAndReadTextFile().test_readCookies(), "User-Agent": "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36", "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8", "Accept-Encoding": "gzip, deflate", "Accept-Language": "zh-CN,zh;q=0.9,en;q=0.8" } self.app_header = { "User-Agent":"Android/8.0", "Content-Type":"application/x-www-form-urlencoded", "Connection":"Keep-Alive", "Accept-Encoding":"gzip" } self.keywords = writeAndReadTextFile().test_read_systemId('呼叫系统')
def __init__(self,): # self.itemData = itemData if '180' in getConstant.IP: self.ip = getConstant.IP+getConstant.PORT_7884 else: self.ip = getConstant.IP self.header = { "Cookie":writeAndReadTextFile().test_readCookies(), "Accept":"application/json, text/javascript, */*; q=0.01", "X-Requested-With":"XMLHttpRequest", "User-Agent":"Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36", "Accept-Encoding":"gzip, deflate", "Accept-Language":"zh-CN,zh;q=0.9,en;q=0.8" } self.timeout = 20
def newPersonnel(obj): # print(obj['mobilephone']) if '180' in getConstant.IP: ip = getConstant.IP + getConstant.PORT_7897 else: ip = getConstant.IP url = ip + '/dcms/bmsAdmin/Admin-save.action' data = { "tempJumpUrl": "", "id": "", "groups": "", "logonpassword": "", "deptId": obj['deptId'], "bgids": "", "bgnms": "", "name": obj['name'], "logonname": obj['logonname'], "password": obj['password'], "position": obj['position'], "phone": obj['phone'], "mobilephone": obj['mobilephone'], "mac": "", "num": obj['num'], "deptname": obj['deptname'], "jobposition": obj['jobposition'], "lead": "", "activation": obj['activation'], "zxcode": "", "zxphone": "", "eno": obj['eno'], "file": "", "bgName": "", "groupnames": "", } header = {"Cookie": writeAndReadTextFile().test_readCookies()} r = requests.post(url=url, data=data, headers=header, allow_redirects=False) # print(r.text) if ('Set-Cookie' not in r.headers or '用户名已经存在' in r.text): print("返回结果", r.text) filename = 'E:/test/dcms/ChengGuan/testFile/newPersonnel/newPresonnel_2.xlsx' wb = wb = openpyxl.load_workbook(filename) ws = wb.active ws.delete_rows(2, 1) #删除index为2后面的2行 wb.save(filename) print("删除成功")
def test_ReportPicture(self, fromDir, colers, targetDir, exportType): imgUrl = self.ip + '/partselection/common/uploadImage.do' imgArr = [] imagepath = self.export(fromDir, colers, targetDir, exportType) # files = os.listdir(imagepath) for img in imagepath: millis = int(round(time.time() * 1000)) img_url = self.ip + '/filemanager/filePathServlet?num=1&type=image&suffix=png&_=' + str( millis) img_rel_res = requests.get(img_url, headers=self.header, allow_redirects=False, timeout=20) img_rel_res.connection.close() imgrelres = img_rel_res.text mystr = imgrelres[2:-2] print("----------------------------", mystr) m = MultipartEncoder( fields={ 'file': ('icon.png', open(img, 'rb'), 'multipart/form-data'), 'type': 'image', 'path': mystr }) header = { "Content-Type": m.content_type, "Cookie": writeAndReadTextFile().test_readCookies() } objsbres = requests.post(imgUrl, data=m, headers=header, allow_redirects=False, timeout=20) objsbres.connection.close() if '服务调用成功' in objsbres.text: obj_result = json.loads(objsbres.text) imgres = json.loads(obj_result['result']) imgpaths = imgres["filePath"] # print("图片地址:",imgpaths) imgArr.append(imgpaths) else: print("XXXXXXXXXX图片出现问题XXXXXXXXXX") return False return imgArr
def test_ReportPicture(self,fromDir,colers,targetDir,exportType): imgUrl = self.ip+'/partselection/common/uploadImage.do' imgArr = [] imagepath = self.export(fromDir,colers,targetDir,exportType) # files = os.listdir(imagepath) for img in imagepath: millis = int(round(time.time() * 1000)) img_url = self.ip+'/filemanager/filePathServlet?num=1&type=image&suffix=png&_='+str(millis) img_rel_res = requests.get(img_url,headers = self.header,allow_redirects = False,timeout = 20) img_rel_res.connection.close() imgrelres = img_rel_res.text mystr = imgrelres[2:-2] m = MultipartEncoder( fields = { 'file':('icon.png', open(img,'rb'),'multipart/form-data'), 'type':'image', 'path':mystr } ) header = { "Content-Type":m.content_type, "Cookie":writeAndReadTextFile().test_readCookies(), "Accept":"application/json, text/javascript, */*; q=0.01", "X-Requested-With":"XMLHttpRequest", "User-Agent":"Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36", "Accept-Encoding":"gzip, deflate", "Accept-Language":"zh-CN,zh;q=0.9,en;q=0.8" } objsbres = requests.post(imgUrl,data = m,headers = header,allow_redirects = False,timeout = 20) objsbres.connection.close() if '服务调用成功' in objsbres.text: obj_result = json.loads(objsbres.text) imgres = json.loads(obj_result['result']) imgpaths = imgres["filePath"] # print("图片地址:",imgpaths) imgArr.append(imgpaths) else: print("XXXXXXXXXX图片出现问题XXXXXXXXXX") return False return imgArr
def __init__(self, loginUser): self.loginUser = loginUser if '180' in getConstant.IP: self.ip = getConstant.IP + getConstant.PORT_7897 else: self.ip = getConstant.IP self.menuId = '8a8a8483666270630166627b02900087' self.keywords = '402880ea2f6bd924012f6c521e8c0034' self.header = { "Cookie": writeAndReadTextFile().test_readCookies(), "Upgrade-Insecure-Requests": "1", "User-Agent": "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36", "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8", "Accept-Encoding": "gzip, deflate", "Accept-Language": "zh-CN,zh;q=0.9,en;q=0.8" }
def __init__(self, loginUser): self.loginUser = loginUser if '180' in getConstant.IP: self.ip = getConstant.IP + getConstant.PORT_7897 else: self.ip = getConstant.IP self.app_header = { "User-Agent": "Android/8.0.0", "Content-Type": "application/x-www-form-urlencoded", "Connection": "Keep-Alive", "Accept-Encoding": "gzip" } self.header = { "User-Agent": "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36", "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8", "Accept-Encoding": "gzip, deflate", "Accept-Language": "zh-CN,zh;q=0.9,en;q=0.8", "Cookie": writeAndReadTextFile().test_readCookies() }
def setUpClass(cls): #放对数据可操作的代码,如对mysql、momgodb的初始化等,这里不对数据库进行操作! # 初始化移动端登录人员集合对象 cls.loginItems = writeAndReadTextFile().test_read_appLoginResult() #获取cookies cls.cookies = writeAndReadTextFile().test_readCookies()
# caseQueryRecordArr = zongHe_List.findAll('caseQueryRecord') # for caseQueryRecord in caseQueryRecordArr: # # print("编码是:",caseQueryRecord.idcase.string, # # "状态是:",caseQueryRecord.casestateid.string) # detailUrl = self.ip+"/dcms/PwasAdmin/PwasAdmin-getImg.action" # detailData = {'caseId':caseQueryRecord.idcase.string} # appDetailRes = requests.post(detailUrl,detailData,headers = self.app_header, allow_redirects=False,timeout = 20) # appDetailRes.connection.close() # if 'success' in appDetailRes.text: # detailObj = json.loads(appDetailRes.text) # if detailObj['data']: # print("案卷详情是:",detailObj['data']) # else: # print("XXXXXXXXXXXX案卷单号:{}该案卷详情中的流转记录有错误XXXXXXXXXXXXX".format(caseQueryRecord.caseid.string)) # else: # print("综合查询列表为空!!!") if __name__ == "__main__": loginItems = writeAndReadTextFile().test_read_appLoginResult() loginItems['markNum'] = [2, 1] # colligateQuery(loginUser).test_web_zongHeList() #综合查询列表 colligateQuery(loginItems).test_web_zongHeDetail() #案卷详情 # colligateQuery(loginItems).test_ExportThisPage() #导出 #app综合查询 # a = colligateQuery(loginItems).test_app_zongHeList() # print(a) #案卷查询列表、案卷详情 # colligateQuery(loginItems).test_app_anJuanDetail()
def test_web_handlingDetailsAndHandling(self): # 获取待处理列表 clres = self.test_web_PendingList() if clres: pattern = re.compile( r'<tr[\s\S]*id="(.*?)"[\s\S]*onclick="casedo[\(](.*?),(.*?),(.*?),(.*?),this[\)]">' ) dclid = pattern.search(clres).group(1) dcl_menuid = pattern.search(clres).group(2).strip("'") dcl_taskprocess = pattern.search(clres).group(5).strip("'") # 待处理详情url dclxq_url = self.ip + "/dcms/cwsCase/Case-dealview.action?id=" + dclid + "&menuId=" + dcl_menuid + "&taskprocess=" + dcl_taskprocess dclxq_cookies = writeAndReadTextFile().test_readCookies() dclxqres = requests.get(url=dclxq_url, headers=self.header) dclxq_res = dclxqres.text dclxqres.connection.close() cl_taskcasestateid = re.compile( '<input type="hidden" id="taskcasestateid" name="taskcasestateid" value="(.*?)"/>' ).search(dclxq_res).group(1) cl_casestate = re.compile( '<input type="hidden" id="casestate" name="casestate" value="(.*?)" />' ).search(dclxq_res).group(1) cl_taskDeptID = re.compile( '<input type="hidden" id="taskDeptID" name="taskDeptID" value="(.*?)" />' ).search(dclxq_res).group(1) cl_applyreturnlist = re.compile( '<input type="hidden" id="applyreturnlist" name="applyreturnlist" value="(.*?)" />' ).search(dclxq_res).group(1) if 'upload' in self.loginUser: upload = self.loginUser['upload'] else: upload = "" # 处理案卷url cl_url = self.ip + "/dcms/cwsCase/Case-deal.action" m = MultipartEncoder( fields={ "taskcasestateid": cl_taskcasestateid, "menuId": dcl_menuid, "casestate": cl_casestate, "id": dclid, "taskprocess": dcl_taskprocess, "taskDeptID": cl_taskDeptID, "resultprocess": self.loginUser['resultprocess'], "applyreturnlist": cl_applyreturnlist, "operatingComments": self.loginUser['operatingComments'], "upload": upload, "dispatchDeptid": "", "dispatchDeptname": "", "limittime": "", "operatingComments_dis": "", "sentence": "" }) cl_header = { "Content-Type": m.content_type, "User-Agent": "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36", "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8", "Accept-Encoding": "gzip, deflate", "Accept-Language": "zh-CN,zh;q=0.9,en;q=0.8", "Cookie": writeAndReadTextFile().test_readCookies() } clresult = requests.post(cl_url, data=m, headers=cl_header) cl_result = clresult.text clresult.connection.close() return cl_result else: print("待处理列表暂无数据!!!") return False
def test_web_UnconfirmedDetail(self): dqrObj = self.test_UnconfirmedDetal() if dqrObj: print("工单对象:", dqrObj) dqrDetail_url = self.ip + "/dcms/ccsCase/Case-callinput.action" dqrData = { "id": dqrObj['oderid'], "menuId": dqrObj['menuId'], "keyword": dqrObj['updateCaseGetUrl'] } dqrDetail_result = requests.get(dqrDetail_url, params=dqrData, headers=self.header, timeout=20) dqrDetail_res = dqrDetail_result.text if '<title>事件录入</title>' in dqrDetail_res: dqr_result = BeautifulSoup(dqrDetail_res, 'html.parser') dqr_sex = dqr_result.find('select', attrs={'id': 'p_sex'}) dqr_select_sourceid = dqr_result.find('select', attrs={'id': 'sourceid'}) dqr_select_needconfirm = dqr_result.find( 'select', attrs={'id': 'needconfirm'}) if self.dataObject != {}: dqr_needconfirm = self.dataObject['needconfirm'] dqr_isFh = self.dataObject['isFh'] else: loginItems = writeAndReadTextFile( ).test_read_appLoginResult() #是否核实 dqr_needconfirm = re.compile( '<option checked="" value="(.*?)">(.*?)</option>' ).search(str(dqr_select_needconfirm)).group(1) #处理方式 dqr_isFh = re.compile( '<input type="hidden" name="isFh" id="isFh" value="(.*?)"/>' ).search(dqrDetail_res).group(1) dqr_casecallId = re.compile( '<input type="hidden" id="casecallId" name="casecallId" value="(.*?)"/>' ).search(dqrDetail_res).group(1) dqr_casesource = re.compile( '<input type="hidden" name="casesource" id="casesource" value="(.*?)"/>' ).search(dqrDetail_res).group(1) dqr_street = re.compile( '<input type="hidden" id="street" name="street" value="(.*?)"/>' ).search(dqrDetail_res).group(1) dqr_p_name = re.compile( '<input type="text" id="p_name" name="p_name" value="(.*?)"' ).search(dqrDetail_res).group(1) # 上报人性别 p_sex = re.compile( '<option selected="(.*?)" value="(.*?)">(.*?)</option>' ).search(str(dqr_sex)) if p_sex != None: dqr_p_sex = p_sex.group(3) else: dqr_p_sex = "" # 案卷来源 dqr_sourceid = re.compile( '<option selected="selected" value="(.*?)">(.*?)</option>' ).search(str(dqr_select_sourceid)).group(1) # 手机号 dqr_other_phone = re.compile( r'<input type="text" id="other_phone" name="other_phone"[\s\S]*value="(.*?)" class="text_sustb">' ).search(dqrDetail_res).group(1) # 案卷id # dqr_id = re.compile('<input type="hidden" id="id" name="id" value="(.*?)"/>').search(dqrDetail_res).group(1) # # 案卷类型 #万米网格 dqr_gridid = re.compile( '<input type="text" id="gridid" readonly name="gridid" value="(.*?)"' ).search(dqrDetail_res).group(1) #描述 dqr_description = re.compile( r'<textarea id="description" cols="30" rows="2" name="description"[\s\S]*class="(.*?)">(.*?)</textarea>' ).search(dqrDetail_res).group(2) # dqr_dealWay = re.compile('<input type="radio" id="(.*?)" name="dealWay" checked>(.*?)</input>').search(dqrDetail_res).group(1) #位置描述 dqr_fieldintro = re.compile( '<textarea id="fieldintro" cols="30" rows="2" name="fieldintro" oninput="(.*?)">(.*?)</textarea>' ).search(dqrDetail_res).group(2) qr_url = self.ip + "/dcms/ccsCase/Case-callToCaseStart.action" webdata = writeAndReadTextFile().test_read_txt( 'E:/test/dcms/ChengGuan/testFile/queRen/querenanjuan_web.txt' ) if 'upload' in self.dataObject: upload = self.dataObject['upload'] else: upload = "" webdata_list = webdata.split(",") m = MultipartEncoder( fields={ "mposl": self.dataObject['mposl'], #经度 "mposb": self.dataObject['mposb'], #纬度 "menuId": dqrObj['menuId'], #菜单id "removeFileId": "", "updateCaseGetUrl": dqrObj['updateCaseGetUrl'], "casecallId": dqr_casecallId, #上报人相关,可为空 "imageid": "", "px": "", "py": "", "deptId": "", "isFh": self.dataObject['isFh'], #是否复核 "casesource": dqr_casesource, #案卷来源 "dispatchDeptname": "", "street": dqr_street, #街道编码 "p_name": dqr_p_name, #上报人名字 "p_sex": dqr_p_sex, #性别 "p_job": "", "p_phone": "", "other_phone": dqr_other_phone, #上报人手机号 "feedback": "", "source.id": dqr_sourceid, #来源统计 "id": dqrObj['oderid'], #工单id "eorc.id": self.dataObject['eorcid'], "eventtypeone.id": self.dataObject['eventtypeone'], #大类 "eventtypetwo.id": self.dataObject['eventtypetwo'], #小类 "startConditionId": "", #这里是立案条件 "regioncode.id": self.dataObject['regioncodeId'], "bgcode.id": self.dataObject['bgcodeId'], "objcode": "", "bgadminid.id": self.dataObject['id'], #管理员id "bgadminid2": self.dataObject['name'], #管理员名称 "gridid": dqr_gridid, #万米网格 "needconfirm": self.dataObject['needconfirm'], #是否核实 "description": dqr_description, #描述 "dealWay": self.dataObject['isFh'], "fieldintro": dqr_fieldintro, #位置描述 "upload": upload #图片 }) header = { "User-Agent": "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36", "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8", "Accept-Encoding": "gzip, deflate", "Accept-Language": "zh-CN,zh;q=0.9,en;q=0.8", "Content-Type": m.content_type, "Cookie": writeAndReadTextFile().test_readCookies() } #重定向没有返回值 webres = requests.post(url=qr_url, data=m, headers=header, allow_redirects=False, timeout=20) web_res = webres.text webres.connection.close() mystr = web_res.find("errorCode") if mystr != -1: print("XXXXXXXXXXweb工单确认失败XXXXXXXXXX") return False elif ('Set-Cookie' in webres.headers): print("对不起请您先登录") return False else: print("web端工单确认完毕") return True elif dqrObj == {}: print("待确认列表中不存在该工单:{}", format(self.dataObject['oderNumber'])) return dqrObj else: print("XXXXXXXXXXX特么异常了XXXXXXXXXX") # if __name__=="__main__": # dataObject = writeAndReadTextFile().test_read_appLoginResult() # # loginUser = loginItems['wggly']['user']#核实人 # # dataObject = {} # dataObject['oderNumber'] = '201903010036' # # dataObject['loginUser'] = loginUser # # dataObject['needconfirm'] = getConstant.NEEDCONFIRM_YES #核实 # # dataObject['isFh'] = getConstant.ISFH_NO #回访 # confirm(dataObject).test_web_UnconfirmedDetail()
def test_web_submitOrder(self): submiturl = self.ip+'/dcms/ccsCase/Case-callToCaseStart.action' if 'upload' in self.orderData: upload = self.orderData['upload'] else: upload = "" m = MultipartEncoder( fields = { "mposl":self.orderData['mposl'], "mposb":self.orderData['mposb'], "menuId":self.orderData['menuId'], "removeFileId":"", "updateCaseGetUrl":"", "casecallId":"", "imageid":"", "px":"", "py":"", "deptId":"", "isFh":self.orderData['isFh'], "casesource":"", "dispatchDeptname":"", "street":self.orderData['street'], "p_name":self.orderData['p_name'], "p_sex":self.orderData['p_sex'], "p_job":self.orderData['p_job'], "p_phone":self.orderData['p_phone'], "other_phone":self.orderData['other_phone'], "feedback":self.orderData['feedback'], "source.id":self.orderData['source'], "id":"", "eorc.id":self.orderData['eorcid'], "eventtypeone.id":self.orderData['eventtypeone'], "eventtypetwo.id":self.orderData['eventtypetwo'], "startConditionId":"", #立案条件 "regioncode.id":self.orderData['regioncode'], "bgcode.id":self.orderData['bgcode'], "objcode":"", "bgadminid.id":self.orderData['bgadminid'], "bgadminid2":self.orderData['bgadminid2'], "gridid":self.orderData['gridid'], "needconfirm":self.orderData['needconfirm'], "description":self.orderData['description'], "dealWay":self.orderData['dealWay'], "fieldintro":self.orderData['fieldintro'], "upload":upload } ) header = { "Content-Type":m.content_type, "Cookie":writeAndReadTextFile().test_readCookies(), "Connection":"keep-alive", "User-Agent":"Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36", "Accept":"text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8", "Accept-Encoding":"gzip, deflate", "Accept-Language":"zh-CN,zh;q=0.9,en;q=0.8" } #重定向没有返回值 webres = requests.post(url = submiturl, data=m, headers=header,allow_redirects=False) webres.connection.close() web_res = webres.text # print("结果",web_res) mystr = web_res.find("errorCode") if mystr != -1: print("XXXXXXXXXXweb工单录入失败XXXXXXXXXX") elif ('Set-Cookie' in webres.headers): print("xxxxxxxxx对不起您未登录,请登录后再上报工单xxxxxxxx") else: print("web工单录入成功") return True
else: print("快速案卷处理时未上传图片") return True else: print("XXXXXXXXXXXXXXXXXXX快速处理案卷失败XXXXXXXXXXXXXXXXXXX") return False else: print("00000000000000待处理快速案卷列表暂时为空0000000000000") return False if __name__ == "__main__": # 快速处理案卷 time.sleep(random.randint(2, 4)) markPath = getConstant.PROJECT_PATH + "/common/numberMark.txt" mark = writeAndReadTextFile().test_read_txt(markPath) dict_mark = json.loads(mark) number = int(dict_mark['zfj_sb']) + 1 loginitems = writeAndReadTextFile().test_read_appLoginResult() loginUser = loginitems['zfj']['user'] millis = int(round(time.time() * 1000)) loginUser['startTimes'] = millis - 24 * 60 * 60 * 1000 loginUser['endTime'] = millis loginUser['describe'] = '快速上报案卷' + str(number) loginUser['eorc'] = getConstant.EORCID_SJ loginUser['fieldintro'] = '吉林市 高新开发区 高新开发区街道 长江社区 长江社区第八网格' loginUser['mposl'] = '14089442.42203088' loginUser['eventtypeone'] = getConstant.SJ_SRHJ loginUser['eventtypetwo'] = getConstant.SJ_SRHJ_DLBJ loginUser['mposb'] = '5436678.363948615'