https://testerhome.com/topics/5631
Since part of the content involves company secrets, it has been replaced with letters, without affecting reading
Actual effectCurrently compatible with all our company apps
Response Body full field validation (with field type)
2 major problems caused by field changes
Try to avoid the influence of the external network data/user on the daily monitoring and running interface
Configuration file
HTTP interface Test Framework configuration informationTester=TesterProject=AVersionname=2.2.2Versioncode= 237host = a-webapi.test.b.com< Span class= "py" >gettokenhost = http://a-webapi.test.b.com/api/system/gettoken< Span class= "py" >loginhost = http://a-webapi.test.b.com/api/user/loginv2 logininfo = phone=13750199962&password=fggiwe5ocdk%3dsessionspath = d:\fiddler Sessions< Span class= "py" >apiurl = http://apihelper.b.com/home/api/c# Specialsessions >> Shielded interface specialsessions = [' GetToken ', ' LoginV2 ', ' LogOut ', ' BookingV2 ']
Start Test Portal
"" "Run API Test Total Entry" "import Sessions. Requestdef launcher_api_test (): "" "1. Get interface List 2. Compare with local sessions 3. diff file, whether continue 3.1 no continue recording interface 3.2 is the start Run interface: return: "" "r = Sessions. Request. Request (0) # 0 >> A 1 >> B r. Start () if __name__ == "__main__" Span class= "P" >: launcher_api_test ()
Header, Login interface
Def__get_token_header(Self):"" "Generate Token Header: return:" "Des=Self.__get_token_des()Arr=(Des,Self.Conf[' SystemType '],Self.Conf[' Model '],Self.Conf[' Release '],Self.Conf[' DeviceId '],Self.Conf[' Versioncode '],Self.Conf[' Versionname '],Self.Conf[' Appbuild '],Self.Conf[' Deviceos '],"0")Authorization=Self.Authorization_token%ArrHeaders={' Content-type ':' application/x-www-form-urlencoded; Charset=utf-8 ',' Authorization ':Authorization}Response=Self.Session.Post(Self.Conf[' Gettokenhost '],Headers=Headers)IfJson.Loads(Response.Text)[' Statscode ']==200:Data1=Json.Loads(Response.Text)[' Data ']Self.Time=Data1[' Time ']Self.Token_name=Data1[' Tokenname ']Self.Token_value=Data1[' Tokenvalue ']Else:Print("GetToken failed, please check manually")Utils.Handlejson.Handlejson.Print_json(Response.Text)Def__login_session(Self):"" "calls the login interface so that the subsequent interface will be properly accessed: return:" "Url_login=Self.Conf[' Loginhost ']Headers=Self.__get_session_header(Url_login.Split(' api/')[-1])Data_login=R%S%Self.Conf[' Logininfo ']Response=Self.Session.Post(Url_login,Headers=Headers,Data=Data_login)IfJson.Loads(Response.Text)[' Statscode ']==200:Data1=Json