# Coding:utf-8Import requests# Open the Login first page to get some cookiesurl = "Https://passport.cnblogs.com/user/signin"headers = {"User-agent": "mozilla/5.0 (Windows NT 10.0; WOW64; rv:44.0) gecko/20100101 firefox/44.0 "} # Get method add a ser-agent to it.s = requests.session ()r = S.get (URL, headers=headers,verify=false)Print S.cookies# Two cookies required to add a loginc = Requests.cookies.RequestsCookieJar ()C.set ('. Cnblogscookie ', ' Here is caught ') # fill up the contents of the
In the past few months, has been engaged in interface testing. Use the Jmeter+jenkins+gitlab tool chain. In fact, there is no technical problem, just in the promotion, the value is not worth our effort to write, to maintain a large number of interface test cases???Last night on-line, today's online affairs, let me completely clear, must be engaged, and quickly and comprehensively spread out.The thing is: th
------"
data = Json.dumps ({"userid": 1, "token": "868d26e05666c5aaeb76d361faa7448c", "ArticleID": [3,4,5]}) #
r = Requests.delete (' http://localhost:8080/delete/', data = data)
Print R.status_code
Print R.text
Print type (R.json ())
Print str (R.json ())
DescriptionIf these interfaces are requested in some interface request plug-ins (such as Httprequester), there is no space between key-value pairs when the parameter is
Namevaluepair, one is to encapsulate the request parameters in the way of Jsonobject, so the code is implemented for both methods. The 3.3 Interface Implementation (Glist_api.java) takes "create G-single" as an example to implement the interface: 3.4 Prepare the test data (Testdata.java) to prepare the test data for the interface. 3.5 test Data parameterization
I. Description of TEST requirementsA series of HTTP interface functional tests on the service backend.Input: Constructs different parameter input values (JSON format) according to the interface descriptionOutput: String (incoming method + incoming string)Http://localhost:8090/lctest/TestServerIi. Framework Design – programming1.Client program DesignReading test case data from an Excel configurationSend para
Python learning notes (interface automation framework) and python learning notes
Previously, we used the unittest test framework provided by python.
This time, I designed one by myself and then added a little more functionality to it.
(Ps: of course, this framework is really very simple .. Very simple... Very simple ...)
Excel File Format:
1 #! /Usr/bin/env python 2 #-*-coding: utf_8-*-3 4 import xlrd 5 im
both students, but also teachers;
5, after the end of the study, you still need to do two things, it depends on whether you want to.
First, you develop automated testing tools to demonstrate to your immediate leadership see, pay 15%, not much?
Second, open your resume, adjust your expected salary position to the next interval;
Note: This is only the beginning, there are more exciting, if you want to understand, please join, and we work together to polish this set of disruptive learning m
Python in the HTTP protocol interface related libraries have URLLIB,URLLIB2 and Reqeusts library, which Reqeusts library for the most convenient, so I also mainly use the requests library to do the interface test HTTP protocol. Let's start by looking at what environment information is needed:First, install PythonThe Mac comes with Python installed, and that's not much to say.Second, install the virtual envi
Business process:1. Provide written test cases, read content2. Then automatically adjust the interface according to the use case content in Excel, determine whether the return value in the expected result is consistent with the value in the return message, generate a test report, send an email to informImplementation steps:1. Read Excel and save the contents of the test case;2. According to the request URL and parameter stitching request message in Ex
# functionA = [1, 3, 6, 4, 85, 32, 46]Print (sum (a)) # sum, Sum functiondef add (): A = 1, b = 2, Return a + bPrint (Add ())def add (A, B): # all required Return a + bPrint (Add ())def add (a=0, b=0): # is not required Return a + bPrint (Add ())def add (A, b=0): # A is required (required fields are put in front) Return a + bPrint (Add (1, 3)) # does not specify the parameter name, and sequentially passes the argumentPrint (Add (a=1, b=3)) # Specify the parameter
'. /guest/settings ' Find ' DATABASES ' change configuration to ' NAME ': ' New database '. Add a marker, or remember to change it backTo.16, the book Time data obsolete processing, need to adjust the data filled in the bookThe tenth chapter of the framework of the Test_data, inside the event data, Start_time must be ahead of the advance.------------------------Split Line, updated on 20180619,------------------------Understanding and summary of the worm master's work "Web
required for all test cases
The Readme note that this is a habitual thing
3. ModuleIn the brain should have a basic initial type, which modules may be used, the following is the need to use the module, calm, the following will be said:
Requests:http Protocol Library
Cx_oracle:python Accessing the Oracle expansion module
Configparser:python Operation profile
XLRD: Manipulating Excel Read-write
Logging:python Log Library
Threading: Threading Module
Json:j
Interface 5: Get all student informationBrief description: Learn how to add header informationRequest Url:http://api.nnzhp.cn/api/user/all_stuRequest method: Get (need to add header information, key is refer value of htt://api.nnzhp.cn, if the value is inconsistent, you can not find all student information)Parameters: None1, click Newtab, select Get, Address bar input Url:http://api.nnzhp.cn/api/user/all_stu2, click Header,key Input Referer,value inpu
+bvrf2knzu35vtkaftqw8qn08tl0ggdzezy= "," Input2 ":" gak4vtm2i+a/6blhriu8/oeekjkav3sru/ds5l3o0bmd/xk6ped0vk8guls6/obv3dl+y8hub2ey9+ Po6ip53kisnkpoeu1y0p0acixmgk0jwcs+ydclgen0krvxnlo/ltcw1hrxvcrbraahrcezdt2otbye4frzkimshhqz+se= "," Remember ": FalsePost/user/signinFollow Response${status} Get Response Status${body} Get Response BodyLog ${body}Log ${status}Execution Result:From the returned results, after the follow response keyword is used, the redirected URL continues with the request, and the la
. Then add the login cookie and fill in the first step fiddler the captured content.c = Requests.cookies.RequestsCookieJar () c.set ('. Cnblogscookie ', ' xxx ') c.set ('. Cnblogs.AspNetCore.Cookies ', ' xxx ') s.cookies.update (c) print (s.cookies)Iv. Reference Code1. Since the login time is more than 2 cookies, we can first use the Get method to open the login home page, to obtain some cookies2. Add the cookie that you want to log in to the session3. After the successful addition, edit the tex
time is more than 1s, the problem will come.(obviously, more than 1s, only the number of decimal parts is intercepted)3. So the correct posture to get response time should be: R.elapsed.total_seconds (), unit is STimeout timed out1. If a request response time is longer, cannot wait, can set a timeout time, let it throw an exception2. The following request, setting timeout of 0.5s, will throw this exception: Requests.exceptions.ConnectTimeout:HTTPConnectionPoolimport requestsr = requests.get("ht
methodR.raise_for_status () #失败请求 (not 200 responses) throws an exceptionLogincookies = r.cookies: # Get logged in cookiess = requests.session () # can use this method to keep the session, not every time to get cookies (only applicable to the website is a cookie, the site is token of useless)Print (r.encoding) # View the encoded format returnedR.json # Gets the JSON returnedVerify=false # When you access an HTTPS request plus do not validate the certificate# Open Excel file, save file as suffix
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.