class CasePack(Station, Share): log = Log() def test_staion_success(self): try: self.charging_station() self.station_item() self.evaluation_item() self.appraise_item() # self.error_correction_item() self.error_position_item() self.collect_item() print("停车场功能测试完毕") except Exception as e: self.getScreenShot() self.log.error(e)
class test_01(unittest.TestCase): log = Log() def setUp(self): print("Start 01") self.log.info("---开始test_01测试任务---") def test_a(self): u'''this注释测试----哇哈哈''' self.log.debug("aaaaahhhh") print("test a") def test_fail(self): self.assertTrue(False, '失败的 test') self.log.debug("aaaaahhhh") def tearDown(self): print("test over")
def mysql_getrows(self,sql,number=None): ''' 返回查询结果''' cur = self.conn.cursor() try: cur.execute(sql) except Exception as a: Log().debug("查询结果错误:%s" % a) # print("查询结果错误:%s" % a) if number == 'one': row = cur.fetchone() return row elif number == 'more': rows = cur.fetchall() cur.close() return rows else: pass cur.close()
def setUp(self): self.s = requests.session() self.lgin = LG(self.s) #实例化登录类 self.uid_token = self.lgin.get_token() #直接取账号登录的token self.auto_login_token = self.lgin.get_autologin_token() #取自动登录的token self.header = { 'User-Agent': 'LanTingDoctor/2.0.2 (iPad; iOS 10.1.1; Scale/2.00)', 'Accept-Encoding': 'gzip, deflate', 'Accept-Language': 'zh-Hans-CN;q=1', 'Content-Type': 'application/json', 'requestApp': '3', 'requestclient': '2', 'versionForApp': '2.0', 'Authorization': 'Basic YXBpTGFudGluZ0BtZWRsYW5kZXIuY29tOkFwaVRobWxkTWxkQDIwMTM=', 'Connection': 'keep-alive' } self.log = Log()
def setUpClass(cls): # log 实例化 cls.log = Log() # 获取创建项目名字 projectName = "审核拒绝项目测试" url = confParam("hostName") + "/api/assets/v2/project-config" cls.asset_headers = {"Content-Type": "application/json;charset=UTF-8", "Authorization": read_token()["assertToken"]} data = {"assetKind": "CREDIT", "projectName": projectName, "projectType": "PRO_CONSUMPTION"} response = requests.post(url, headers=cls.asset_headers, data=json.dumps(data)) # 数据库实例化 db = dataBase() cls.config_number = db.configId("id", "loan_project_config", "project_name", projectName) cls.url = confParam("hostName") + "/api/center/v2/project-config/_audit-failure" cls.headers = {"Content-Type": "application/json;charset=UTF-8", "Authorization": read_token()["centerToken"]}
def __init__(self,url_json): self.url_json = url_json r = requests.get(self.url_json + '/swagger/v1/swagger.json').json() self.title = r['info']['title'] write_data(r,'{}.json'.format(self.title)) #创建文件 self.interface_params = {} self.log = Log() self.row = 2 #写入Excel起始行数 self.num = 1 #case id global title_list,json_path if self.check_data(r): self.json_path = os.path.abspath( os.path.dirname( os.path.dirname(__file__))) + '\\data_new' + '\\{}_data.json'.format( self.title) # json file path,执行多个url的情况,区分生成的json文件 # self.data = r['paths'] # paths中的数据是有用的 self.data = r['paths'] title_list.append(self.title)
class Blog_login(unittest.TestCase): log = Log() def login(self, username, psw, reme=True): '''三个参数: 账号:username,密码:psw,记住登录:reme=True''' url = "https://passport.cnblogs.com/user/signin" header = { "User-Agent": "Mozilla/5.0 (Windows NT 10.0; WOW64; rv:44.0) Gecko/20100101 Firefox/44.0", "Cookie": "这里是抓包后获取的cookies", "X-Requested-With": "XMLHttpRequest", "Connection": "keep-alive", "Content-Length": "385" } json_data = {"input1": username, "input2": psw, "remember": reme} res = requests.post(url, headers=header, json=json_data, verify=False) result1 = res.content # 字节输出 self.log.info("博客园登录结果:%s" % result1) return res.json() # 返回json def test_login1(self): u'''测试登录:正确账号,正确密码''' self.log.info("------登录成功用例:start!---------") username = "******", self.log.info("输入正确账号:%s"%username) psw = "这里是抓包后获取的博客园的加密密码", self.log.info("输入正确密码:%s" % psw) result = self.login(username, psw) self.log.info("获取测试结果:%s" % result) self.assertEqual(result["success"], True) self.log.info("------pass!---------") def test_login2(self): u'''测试登录:正确账号,错误密码''' self.log.info("------登录失败用例:start!---------") username = "******", self.log.info("输入正确账号:%s" % username) psw = "xxx", self.log.info("输入错误密码:%s" % username) result = self.login(username, psw) self.log.info("获取测试结果:%s" % result) self.assertEqual(result["success"], False) self.log.info("------pass!---------")
class VerificationCodeTestCase(unittest.TestCase): '''获取验证码''' log = Log() def setUp(self): self.headers = { "Accept-Encoding": "gzip", "Connection": "Keep-Alive", "Content-Type": "application/x-www-form-urlencoded", "Host": "testapi.mrpyq.com", "mpc-mac": "cc%3Aa2%3A23%3Aa4%3A41%3A33", "mpc-network": "none", "mpc-os": "19", "mpc-token": "865166020012616", "mpc-type": "HUAWEI+MT7-TL00", "mpc-ver": "3.1.0", "User-Agent": "MingPeng/3.1.0" } self.data = {"access_token": "", "phone_areacode": "+86"} self.url = "https://testapi.mrpyq.com/pass/send_phone_code_new" def test_VerificationCode_Register(self): '''注册页面测试获取验证码''' self.headers["Content-Length"] = "63" self.data["phone"] = 18872215422 self.data["action"] = "reg" r = requests.post(self.url, headers=self.headers, data=self.data) print(r.content) result = r.json() print(result) # 断言:测试结果与期望结果对比 self.assertEqual(result["result"], 1, msg='验证码发送失败') def test_VerificationCode_Login(self): '''免密登陆页面测试获取验证码''' self.headers["Content-Length"] = "65" self.data["phone"] = 13510405322 self.data["action"] = "login" r = requests.post(self.url, headers=self.headers, data=self.data) print(r.content) result = r.json() print(result) # 断言:测试结果与期望结果对比 self.assertEqual(result["result"], 1, msg='验证码发送失败')
class Blog(): # s = requests.session() log = Log() def __init__(self, s): self.s = s def login(self): url = "http://tac.deloitte.com/4thTest/user/login" headers = { "Connection": "keep-alive", "Content-Length": "158", "Accept": "application/json, text/javascript, */*; q=0.01", "Origin": "http://tac.deloitte.com", "X-Requested-With": "XMLHttpRequest", "User-Agent": "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36", "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8", "Referer": "http://tac.deloitte.com/4thTest/login.html", "Accept-Encoding": "gzip, deflate", "Accept-Language": "zh-CN,zh;q=0.9", # "Cookie": "bi_cookieid=15312066551784671718900; JSESSIONID=BE4AEC522F283186B315DA5F2E2CF16D; 4thCookieAd=; BIGipServerRA_Nginx_98_pool=!6QEU9fBK2WV4AdpfPQCamq130Nw0skj3uLZLS1VlVzFwcVu6IEixgaEVAH9AuYyyPmjLDUjX466QgDM=; i18next=ch" } value = str({ "userName": "******", "password": "******", "verificationCode": "e6dc169a788dddaf65d2a185e06a9c48", "isAuto": 0 }) b = value.replace(" ", "") c = b.replace('\'', '\"') d = {"args": c} s = requests.session() r = s.post(url, headers=headers, data=d, verify=False) print r.content def logout(self): url = "http://tac.deloitte.com/4thTest/user/logout" s = requests.session() r = s.get(url, headers=False, allow_redirects=False) print r.status_code print r.headers print r.headers["Location"]
class Verify_login(unittest.TestCase): ver = Bzj_login() log = Log() #1.正确的账号密码 def test_login1(self): u'''登录用例,正确账号密码''' self.log.info("===start====") phone = "15130078689" credential = "123456" result = self.ver.login(phone, credential) self.log.info(u'''调取登录结果:%s''' % result["msg"]) # # 在调用函数后打印返回值 #print(result) self.assertEqual(result["code"], '100100') # self.assertEqual(result["msg"],'请求成功' ) # self.assertEqual(result["result"]["phone"],"15130078689") self.log.info("===end====")
def setUp(self): self.s = requests.session() self.lgin = LG(self.s) #实例化登录类 self.uid_token = self.lgin.login() self.header = { 'User-Agent': 'LanTingDoctor/1.3.1 (iPad; iOS 10.1.1; Scale/2.00)', 'Accept-Encoding': 'gzip, deflate', 'Accept-Language': 'zh-Hans-CN;q=1', 'Content-Type': 'application/json', 'requestApp': '3', 'requestclient': '2', 'versionForApp': '2.0', 'Authorization': 'Basic YXBpTGFudGluZ0BtZWRsYW5kZXIuY29tOkFwaVRobWxkTWxkQDIwMTM=', 'Connection': 'keep-alive' } self.EXCEL = Excel_util( r'C:\Users\Administrator\Desktop\Interface_testcase.xls') self.log = Log()
def main(): args = parse_args() banner() queue = Queue() log_level = 1 if args.verbose else 2 # 1: INFO, 2: WARNING log = Log(args.output, log_level) cfg = {"logger": log, "queue": queue} read_urls(args.url, args.input, queue) print "Start CORS scaning..." threads = [gevent.spawn(scan, cfg) for i in range(args.threads)] try: gevent.joinall(threads) except KeyboardInterrupt, e: pass
def __read_yaml(path, test_file, test_url, token=None, Authorization=None): ''' :param path: :param test_file: :param test_url: :return: ''' try: yaml_data = open(path + test_file, encoding="utf-8") test_data = yaml.load(yaml_data) for i in test_data: i['url'] = test_url + i['url'] if token != None: i['header']['access_token'] = token if Authorization != None: i['header']['Authorization'] = 'Basic ' + Authorization return test_data except Exception as e: Log().error('文件读取失败:{0}'.format(e))
def setUp(self): self.s = requests.session() self.auto_login_token = auto_login_by_UID() #auto_login_by_UID返回的token self.header = { 'User-Agent': 'PelvicFloorPersonal/4.1.1 (iPad; iOS 10.1.1; Scale/2.00)', 'Accept-Encoding': 'gzip, deflate', 'Accept-Language': 'zh-Hans-CN;q=1', 'Content-Type': 'application/json', 'requestApp': '2', 'requestclient': '2', 'versionForApp': '4.1.1', 'Authorization': 'Basic YXBpTGFudGluZ0BtZWRsYW5kZXIuY29tOkFwaVRobWxkTWxkQDIwMTM=', 'Connection': 'keep-alive' } self.log = Log() self.excel = Excel_util( r'C:\Users\Administrator\Desktop\Interface_testcase.xls')
class CasePack(Carpack, Share, unittest.TestCase): log = Log() def test_mineDynamic_success(self): '''正常存在我的动态''' try: self.car_pack() self.search_pack() self.normal_list() self.details_shares() # self.share_report() self.share_shares_share() self.share_call_off() print("停车场测试完成") except Exception as e: self.getScreenShot() self.log.error(e)
def setUpClass(cls): # log 实例化 cls.log = Log() # 获取创建项目名字 projectName = confParam("projectName") # 数据库实例化 db = dataBase() cls.config_number = db.configId("id", "loan_project_config", "project_name", projectName) cls.url = confParam( "hostName") + "/api/center/v2/project-config/_audit-success" cls.headers = { "Content-Type": "application/json;charset=UTF-8", "Authorization": read_token()["centerToken"] }
class Blog(): # s = requests.session() log = Log() def __init__(self, s): self.s = s def login(self): url = "http://tac.deloitte.com/4thTest/dynamic/find" headers = { "Connection": "keep-alive", "Content-Length": "158", "Accept": "application/json, text/javascript, */*; q=0.01", "Origin": "http://tac.deloitte.com", "X-Requested-With": "XMLHttpRequest", "User-Agent": "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36", "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8", "Referer": "http://tac.deloitte.com/4thTest/login.html", "Accept-Encoding": "gzip, deflate", "Accept-Language": "zh-CN,zh;q=0.9", "Cookie": "bi_cookieid=15312066551784671718900; JSESSIONID=BE4AEC522F283186B315DA5F2E2CF16D; 4thCookieAd=; BIGipServerRA_Nginx_98_pool=!6QEU9fBK2WV4AdpfPQCamq130Nw0skj3uLZLS1VlVzFwcVu6IEixgaEVAH9AuYyyPmjLDUjX466QgDM=; i18next=ch" } a = { "username_": "admin", "password_": "1", "selector": "", "pas": "******" } print a s = requests.session() r = s.post(url, headers=headers, data=a, verify=False) print r.status_code
def setUp(self): #self.url = 'http://api.lesson.sunnycare.cc/v1/orderHistory' #测试环境接口地址 self.url = 'http://api.exam.sunnycare.cc/v1/orderHistoryNew' self.s = requests.session() self.lgin = LG(self.s) #实例化登录类 self.uid_token = self.lgin.login() #直接取第二部登录 self.header = { 'User-Agent': 'LanTingDoctor/1.3.1 (iPad; iOS 10.1.1; Scale/2.00)', 'Accept-Encoding': 'gzip, deflate', 'Accept-Language': 'zh-Hans-CN;q=1', 'Content-Type': 'application/json', 'requestApp': '3', 'requestclient': '2', 'versionForApp': '2.0', 'Authorization': 'Basic YXBpTGFudGluZ0BtZWRsYW5kZXIuY29tOkFwaVRobWxkTWxkQDIwMTM=', 'Connection': 'keep-alive' } self.log = Log()
def setUp(self): self.log = Log() self.s = requests.session() self.lgin = LG() #实例化登录类 self.uid_token = self.lgin.gettoken_loginbyUID() #直接取第二部登录 self.header = { 'User-Agent': 'LanTingDoctor/1.3.1 (iPad; iOS 10.1.1; Scale/2.00)', 'Accept-Encoding': 'gzip, deflate', 'Accept-Language': 'zh-Hans-CN;q=1', 'Content-Type': 'application/json', 'requestApp': '3', 'requestclient': '2', 'versionForApp': '2.0', 'Authorization': 'Basic YXBpTGFudGluZ0BtZWRsYW5kZXIuY29tOkFwaVRobWxkTWxkQDIwMTM=', 'Connection': 'keep-alive' } self.set_nonce = Hash.get_md5(Hash.get_str()) self.set_sign = Hash.get_md5(Hash.get_str())
class TestSearch(): log = Log() def setup_class(self): data = pd.read_csv("D:\Python\Scripts\lvmama\cases\login_data.csv", encoding='gb18030') df = pd.DataFrame(data) self.songs=df['songs'] self.respect=df['respect'] self.actural=df['actural'] def test_searchsongs01(self): #s是需要搜索的关键字 base_url = "http://music.163.com/weapi/cloudsearch/get/web" self.log.info("-------------start:search_songs----------") data = { 's':self.songs[0], 'offset': 0, 'limit': 100, 'type': 10 } payload=encrypted_request(data) r=requests.post(base_url,data=payload) self.result=r.json() assert r.status_code == self.respect[0] #self.log.info(u"查询成功: %s"%self.result["code"]) self.log.info("-------------end:search_songs----------") #return(self.result['result']['albums'][2]['id']) def test_searchsongs2(self): #@pytest.mark.skip(reason="no way of currently testing this") self.base_url = "http://music.163.com/weapi/cloudsearch/get/web" self.log.info("-------------start:search_songs02----------") data = { 's':self.songs[1], 'offset': 0, 'limit': 100, 'type': 10 } payload = encrypted_request(data) r = requests.post(self.base_url, data=payload) self.result = r.json() assert r.status_code == self.respect[1] #self.log.info(u"查询成功: %s" % self.result["code"]) self.log.info("-------------end:search_songs----------")
class GeRen(unittest.TestCase): log = Log() @classmethod def setUpClass(cls): cls.driver = browser() cls.GR = Geren(cls.driver) cls.GR.open(login_url, u'登录') cls.driver.implicitly_wait(5) Global_function.login(cls) @classmethod def tearDownClass(cls): cls.driver.quit() def test_GRXX1(self): ''' :修改用户名称 :return: ''' self.log.info('------修改用户名称:start!---------') self.GR.assertion_test1() self.GR.assertion_test2() self.GR.assertion_test3(read_Data.getExcel2(7, 6)) self.assertEqual(self.GR.assertion_test5(), read_Data.getExcel2(7, 6)) self.log.info('------修改用户名称:stop!---------') def test_GRXX2(self): ''' :修改密码 :return: ''' self.log.info('------修改密码:start!---------') self.GR.assertion_test1() self.GR.assertion_test2() self.GR.assertion_test4(read_Data.getExcel2(8, 6), read_Data.getExcel2(8, 6), read_Data.getExcel2(8, 6)) print('修改后的密码为:%s' % read_Data.getExcel2(8, 6)) self.log.info('------修改密码:stop!---------')
def post(self, url, **dataset): params = dataset.get('params') headers = dataset.get('headers') data = dataset.get('data') json = dataset.get('json') files = dataset.get('files') lg = Log() try: resp = requests.post(url, params=params, headers=headers, data=data, json=json, files=files, timeout=5) status_code = resp.status_code text = resp.json() return text, status_code except Exception as e: lg.info(u'post请求错误:%s' % e)
class CaseLogout(Logout, unittest.TestCase): log = Log() def test_logout_success(self): '''正常退出''' try: self.click_user() time.sleep(2) self.click_setting() time.sleep(2) self.click_logout() time.sleep(2) self.click_confirm_logout() self.log.info('退出成功') except Exception as e: self.assertEqual(self.logout_success(), 'cn.maitian.app.fz:id/btn_login_commit', msg='退出登录失败') self.getScreenShot() self.log.error(e)
def post(self, url, **kwargs): '''封装yyj方法''' # 获取请求参数 log = Log() params = kwargs.get("params") data = kwargs.get("data") json = kwargs.get("json") files = kwargs.get("files") headers = kwargs.get("headers") try: result = requests.post(url, params=params, data=data, json=json, files=files, headers=headers) log.info(result.content.decode('utf-8')) return result except Exception as e: print("post请求错误: %s" % e)
def test_orderone(self): u'''订单页面一''' for z in range(4, 7): self.com.elm_click(z) self.com.elm_operate(7, "") time.sleep(4) self.com.get_dbtext(1, self.getparam[self.i]['parama']) self.com.elm_operate(8, "") time.sleep(1) self.com.get_dbtext(0, self.getparam[self.i]['paramb']) self.com.elm_operate(9, "") time.sleep(1) self.com.get_dbtext(0, self.getparam[self.i]['paramc']) self.com.elm_operate(10, "") time.sleep(1) self.com.elm_operate(11, "") self.com.elm_allson_send(12, 13, 0, self.getparam[self.i]['paramd']) self.com.elm_allson_send(12, 13, 1, self.getparam[self.i]['parame']) self.com.elm_operate(14, "") Log().info("订单页面一完成")
class Blog(): log=Log() def login(self): url="https://passport.cnblogs.com/user/signin" headers={ "User-Agent":"Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36" } s=Session() r=s.get(url,headers=headers,verify=False) cookies={'.CNBlogsCookie':'43A0DE43EAF0EE25D667E898D8C2E915AF343D1B9E046FA6F324496D248340BF5CDC4F88E017F7A2E6FBB775D53220C4F34849BC8249483C4F771BBCDB0BCB38403A7BF46F993F713BAE0A703AF993D24E1C0D96', '.Cnblogs.AspNetCore.Cookies': '=CfDJ8FHXRRtkJWRFtU30nh_M9mDCozlk4STR6Jqgw4OaQcw3qCnCWlmDOrqOTZe0YI90M9U2kzRtIq_NjqWy3GvbeA7QB-ZV8SlMRjuIgyn6GeT9Wt4kcoRNwUc3hnOL_SN74gzx2CKJU4EaZcmohkW9HBe4CSgQrSEIs9R_gFvUzw4bhapvNxyPKkhn1sfxTNCZ4a2WEOG8pFmIfAfmp5w1UCtXgMI9d0oeJjThjOJ1r6p_jqniLpTl64xciR8ci2o9-EXtfdHLNrqMHsAxc9qFo5H1oWBUxAcmbxHVDUIMCN8n'} url1="https://i.cnblogs.com/EditPosts.aspx?opt=1" body = {"__VIEWSTATE": "", "__VIEWSTATEGENERATOR": "FE27D343", "Editor$Edit$txbTitle": "这是3111", "Editor$Edit$EditorBody": "<p>这里111:http://www.cnblogs.com/yeki/</p>", "Editor$Edit$Advanced$ckbPublished": "on", "Editor$Edit$Advanced$chkDisplayHomePage": "on", "Editor$Edit$Advanced$chkComments": "on", "Editor$Edit$Advanced$chkMainSyndication": "on", "Editor$Edit$Advanced$txbEntryName": "", "Editor$Edit$Advanced$txbExcerpt": "", "Editor$Edit$Advanced$tbEnryPassword": "", "Editor$Edit$lkbDraft": "存为草稿", } r2=s.post(url1, headers=headers, verify=False,data=body) self.log.info(u'保存数据成功,保存后的地址为:%s'%r2) # 第三步:正则提取需要的参数值 import re postid = re.findall(r"postid=(.+?)&", r2.url) # 提取为字符串 self.log.info(u'需要删除的字段id为:%s'%postid ) ##删除 url3="https://i.cnblogs.com/post/delete" json3={"postId":postid[0]} r3=s.post(url3,headers=headers,verify=False,json=json3) self.log.info("删除后的结果为:%s"%r3.json())
class Blog(): # s = requests.session() log = Log() def __init__(self, s): self.s = s def register(self): url = "http://tac.deloitte.com/4thTest/user/register" headers = { "Connection": "keep-alive", "Content-Length": "158", "Accept": "application/json, text/javascript, */*; q=0.01", "Origin": "http://tac.deloitte.com", "X-Requested-With": "XMLHttpRequest", "User-Agent": "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36", "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8", "Referer": "http://tac.deloitte.com/4thTest/user/register", "Accept-Encoding": "gzip, deflate", "Accept-Language": "zh-CN,zh;q=0.9", # "Cookie": "bi_cookieid=15312066551784671718900; JSESSIONID=BE4AEC522F283186B315DA5F2E2CF16D; 4thCookieAd=; BIGipServerRA_Nginx_98_pool=!6QEU9fBK2WV4AdpfPQCamq130Nw0skj3uLZLS1VlVzFwcVu6IEixgaEVAH9AuYyyPmjLDUjX466QgDM=; i18next=ch" } a = str({ "mobile": "18883754450", "code": "482000", "email": "*****@*****.**", "password": "******", "protocol": 1, "industry": "农、林、牧、渔业", "industryCode": "A", "companyName": "sdf" }) b = a.replace(" ", "") c = b.replace('\'', '\"') d = {"args": c} print d s = requests.session() r = s.post(url, headers=headers, data=d, verify=False) print r.content print r.status_code
class Womovie(object): log = Log() config = ReadConfig() excel_path = os.path.join(config.get_excel("path"), "login_data.xlsx") excel = ExcelUtil(excel_path, "帐号") def __init__(self, s): self.s = s def login(self, username, psw): """登录""" url = "http://61.171.24.229:5040/IosAiMovie/AiMovie/inputPassword" ret = self.s.get(url) # 提取登录Token form_token = re.findall(r"id=\"Token\" value=\"(.+?)\"", ret.text)[0] self.log.info("登录参数:FormToken=%s" % form_token) # 提取FormDate form_date = re.findall(r"id=\"Date\" value=\"(.+?)\"", ret.text)[0] self.log.info("登录参数:FormDate=%s" % form_date) # 提取__RequestVerificationToken pattern = r"<input name=\"__RequestVerificationToken\" type=\"hidden\" value=\"(.+?)\" />" verification_token = re.findall(pattern, ret.text)[0] self.log.info("登录参数:__RequestVerificationToken=%s" % verification_token) # 登录url url1 = "http://61.171.24.229:5040/IosAiMovie/MySlefContent/IosLoginIn" headers = { "X-Requested-With": "XMLHttpRequest", "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8", "__RequestVerificationToken": verification_token } data = { "account": username, "password": psw, "isSMS": False, "FormToken": form_token, "FormDate": form_date, "IMEI": None } self.s.post(url1, data, headers)
def __init__(self): url_json = 'http://xxx.com/v2/api-docs?group=sign-api' # json swagger url地址 r = requests.get(url_json).json() self.json_path = os.path.abspath( os.path.dirname(os.path.dirname(__file__)) ) + '\\case_generate' + '\\data' + '\\data.json' # json file path self.excel_path = os.path.abspath( os.path.dirname(os.path.dirname(__file__)) ) + '\\case_generate' + '\\data' + '\\demo_api.xlsx' # case path self.interface_params = {} self.log = Log() self.row = 2 # 写入excel起始行数 self.num = 1 # case id self.case = { '1': 3, '2': 5, '3': 7, '4': 9 } # 参数为空,错误的情况 目前可以获取到的参数,最多4个,有9种简单的异常情况 if self.check_data(r): self.data = r['paths'] # paths中的数据是有用的
def capital_sel(self, capital_val): try: if capital_val == '轮循': print("资金模式取数据库当前存储值,轮循切换") capval = MysqlUtil().mysql_getrows( "SELECT t.capital_source,t.l_amount FROM mobiletest_capitallx t WHERE t.capital_source<>'资金cookie'" ) for i in range(10): OracleUtil(dbname).oracle_sql( "update dafy_sales.Partner_Polling_Config set limit_amount='%s' where credit_model='%s'" % (capval[i][1], capval[i][0])) else: OracleUtil(dbname).oracle_sql( "update dafy_sales.Partner_Polling_Config set limit_amount=200000000 where credit_model='%s'" % capital_val) OracleUtil(dbname).oracle_sql( "update dafy_sales.Partner_Polling_Config set limit_amount=0 where credit_model<>'%s'" % capital_val) self.capital_refresh() except Exception as e: Log().info("资金池刷新异常")