In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
Interface testing entry tool Requests how to use, many novices are not very clear about this, in order to help you solve this problem, the following editor will explain for you in detail, people with this need can come to learn, I hope you can gain something.
Origin
As we all know, automated testing is a lifelong research topic for software testing enthusiasts. In my opinion, as long as the interface test is done well, your automated test will be at least half successful.
At the request of some enthusiastic readers, I will join you today to understand and practice the basic usage of the python interface test library-Requests.
What is Requests in the text?
Simply put, Requests is a python library that encapsulates http/https requests.
How do I install Requests?
To put it more simply, the pip method is good:
Pip install requests
How to use Requests? Get request sample code import requests
Test = requests.get ('http://www.baidu.com')
Print (test)
Console output
Process finished with exit code 0
Congratulations, we successfully issued the first get request to Baidu home page. The return value of requests.get is a Response object. You can clearly see that the returned status code is 200.
Post request sample code
This time let's simulate a post request with parameters.
Import requests
Test = requests.post (url=' http://47.106.10.19:5098/api/login',
Json= {'username':' test', 'password':' test'}. Text
Print (test)
Console output {
''
Omit
''
"status": "ok"
}
Process finished with exit code 0
The requested address is the login interface of the Tester platform experience address. The requested parameters are data in json format, including the correct account number and password.
After taking the text attribute on the returned Response object, you can clearly see that the status in the data returned by the API is ok, that is, the login is successful.
Is it helpful for you to read the above content? If you want to know more about the relevant knowledge or read more related articles, please follow the industry information channel, thank you for your support.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.