current position：Home>Python interface automation testing framework -- if you want to do well, you must first sharpen its tools
Python interface automation testing framework -- if you want to do well, you must first sharpen its tools
2022-01-30 20:33:39 【I am the white moonlight you can't get】
「 This is my participation 11 The fourth of the yuegengwen challenge 1 God , Check out the activity details ：2021 One last more challenge 」
The author has opened... In other technical forums 3 A fee column , Average monthly profit since its opening 100 about , From the standpoint of the author , I feel a little flattered , But from the standpoint of readers , But it's a little flawed , First, the directory structure is not systematic , It's a bit of a patchwork ; Second, the length of the content is not clear enough , Some are all code , Some concepts are not explained thoroughly . Then it was pulled by the Nuggets operation boss to Nuggets development , Abandon it , No time to optimize , The author himself is deeply disturbed , A little disappointed by the fans' wrong love ; With this, Nuggets operate , Recombing , Although the nuggets can't be exchanged for cash , But the monthly rewards are more abundant .
From the author's testing position itself , Whether in the famous technology forum or the circle itself , All seem a little insignificant ; Therefore, the author also hopes to show himself through such a platform . The author has been engaged in assembly line before QC（JQE）、 Embedded software testing ( Partial hardware )、 Game testing 、OA The system test ( Internet )、 Credit card system test ( Finance )、P2P software test ( Officially enter the Internet software industry ) And so on , The post level has also moved from a step-by-step to a management post ( Um. , It's a technical route ). Although there is still a long way to go from high rank ( This is also a certain opportunity ), But no one can be a stumbling block to the progress of the author's efforts , Come on! , Middle aged uncle .
Interface automation testing
Before building the framework , Something you should understand
What is interface testing
Interface test is a test to test the interface between system components . The interface test is mainly used to detect the interaction points between the external system and the system as well as between the internal subsystems . The focus of the test is to check the exchange of data , Transfer and control the management process , And the mutual logical dependence between systems .
-- – Baidu Encyclopedia
Why choose python
Why not java Or other programming languages ？ In fact, this wave was brought on fire by online training institutions , Under the 0 Basics 、 Easy to learn 、 Easy to get started ‘ Cover ’‘ cheat ’ Come in, a group of little lambs lost on the test road , But the same is true ;Python It does have the advantage of fire , Engage in interface /UI Automated testing is more than enough . Don't believe it ？ You'll know when you start learning , It's better to listen to it a hundred times than to practice it once .
What is automated testing
The purpose of this concept is to save resources 、 Introduced to improve efficiency , This has also become the most eye-catching high-frequency word in online test training in recent years , Even going out to find a job in a testing position , I don't know about automated testing , I'm sorry to go out for an interview . Let's look at the definition of Baidu Encyclopedia ：
Automated testing is a process that transforms human driven testing behavior into machine execution . Usually , In designing The test case And after passing the review , The tester executes the test step by step according to the procedure described in the test case , Get the comparison between the actual results and the expected results . In the process , In order to save manpower 、 Time or hardware resources , Improve test efficiency , Then introduced the automated testing The concept of .
How to learn interface automation test well
The author can say to everyone , First of all, you should know how to do interface testing , Whether it's using tools or coding , The principle is the same ; Then implement a set of interface automation test scheme with tools , Finally, it is realized by coding again ！ Maybe some students asked , Why don't you code it directly ？ Um. ... Start with getting started with testing , Not everyone has a precise career plan , For example, the author , Most automation technologies are introduced by tools , This is also the current situation of most testing practitioners , At first I heard that testing is easy to get started 、 High wages ( Compared with other industries )、 It can even be understood as more money and less work , So is that really the case ？ A few years later , Differentiation is particularly evident .（ Um. , The author is 7 Years later, I began to learn automatically , More ashamed ） Further back, the test post is a difficult barrier for both salary and level . The author often preaches , First, I will a set of tools to automate the test solution , Then code to realize a set of , All of them have realized the core functions of the tool , Though not UI So what ,.
If a worker wants to do a good job, he must sharpen his tools first , This article is about the environment , Don't talk about any code and implementation logic
python Installation of environment
Version selection python3.5 above , Don't ask why it's not python2, Another question is python4 On python Download from the official website
- Let's foretell , stay python Before development , Get used to using virtual development environments , One is to facilitate migration , Second, environmental isolation .
- As for the choice of virtual environment , One is python -m env /path; Second, choose other virtual environment tools ; The third is Anaconda; Choose demo later
- Every man has his hobbyhorse , The download to install process will not be demonstrated here , See the effect directly ,win Take the system as an example to set up cmd Window type python -V
You can see the current python edition ：Python 3.10.0
IDE Development tool installation
python Have their own development tools , Such as Pycharm, It has two versions , Enterprise edition and Community Edition
- Every man has his hobbyhorse , The author likes to use eclipse, Because the author will be half hanging Java, So in eclipse Development is easier .
- eclipse install Pydev Just plug in .
stay Eclipse Of help--install new software in , Click on ADD Name input Pydev, Link address input ：pydev.org/updates And then choose PyDev:dl.bintray.com/fabioz/pyde… , The other can not choose . You can download , Then make sure to go down step by step .
After installation , restart eclipse take effect .
- tips: eclipse And pydev Version correspondence of , The author suggests that beginners use Pycharm, I can't change myself .
The programmer's first program Hello World.
- stay eclipse establish python project , establish HelloWorld.py file , Input ：
print("Hello World！") Copy code
Right click execution , Console output ： Hello World！
- stay cmd Input python Get into ipython Interactive interface , Output print("Hello World!") enter ：
- In the first way, after creating the file and entering the code , go back to cmd Command window , Enter the project directory , perform python HelloWorld.py, give the result as follows :
It's just done python Environment to IDE Installation and deployment of tools , This is no problem for the environment itself , If you want to do interface testing , Maybe not enough , Need to rely on python Only the third-party library can complete the interface test , that pip This installation tool will be useful , It's like npm On node equally .
- pip install requests # The installation process is a little bit ; You can specify the installation version requests==2.4.3, The default installation is the latest version
requests Is the main tool to complete interface testing
- Use effect demonstration :
import requests res=requests.get("http://www.baidu.com") print(res.text) Copy code
Request Baidu website to get the result is its source code , I won't post it here
thus , The interface test python Development environment deployment is complete .
On the blackboard , On the blackboard , On the blackboard ！！！
Attention! , The key is coming. . In actual use , There may be dependent library versions and python Version is not compatible , But don't panic , It is recommended to use a stable version between the two , Another problem is the virtual environment , Remember to isolate the environment . At the end , I wish you all a pleasant study of interface automation testing ！！！
author[I am the white moonlight you can't get],Please bring the original link to reprint, thank you.
The sidebar is recommended
- Introduction to python (IV) dynamic web page analysis and capture
- leetcode 119. Pascal's Triangle II（python）
- leetcode 31. Next Permutation（python）
- [algorithm learning] 807 Maintain the city skyline (Java / C / C + + / Python / go / trust)
- The rich woman's best friend asked me to write her a Taobao double 11 rush purchase script in Python, which can only be arranged
- Glom module of Python data analysis module (1)
- Python crawler actual combat, requests module, python realizes the full set of skin to capture the glory of the king
- Summarize some common mistakes of novices in Python development
- Python libraries you may not know
- [Python crawler] detailed explanation of selenium from introduction to actual combat 
guess what you like
This is what you should do to quickly create a list in Python
On the 55th day of the journey, python opencv perspective transformation front knowledge contour coordinate points
Python OpenCV image area contour mark, which can be used to frame various small notes
How to set up an asgi Django application with Postgres, nginx and uvicorn on Ubuntu 20.04
Initial Python tuple
Introduction to Python urllib module
Advanced Python Basics: from functions to advanced magic methods
Python Foundation: data structure summary
Python Basics: from variables to exception handling
Python notes (22): time module and calendar module
- Python notes (20): built in high-order functions
- Python notes (17): closure
- Python notes (18): decorator
- Python notes (16): generators and iterators
- Python notes (XV): List derivation
- Python tells you what timing attacks are
- Python -- file and exception
- [Python from introduction to mastery] (IV) what are the built-in data types of Python? Figure out
- Python code to scan code to pay attention to official account login
- [algorithm learning] 1221 Split balanced string (Java / C / C + + / Python / go / trust)
- Python notes (22): errors and exceptions
- Python has been hidden for ten years, and once image recognition is heard all over the world
- Python notes (21): random number module
- Python notes (19): anonymous functions
- Use Python and OpenCV to calculate and draw two-dimensional histogram
- Python, Hough circle transformation in opencv
- A library for reading and writing markdown in Python: mdutils
- Datetime of Python time operation (Part I)
- The most useful decorator in the python standard library
- Python iterators and generators
- [Python from introduction to mastery] (V) Python's built-in data types - sequences and strings. They have no girlfriend, not a nanny, and can only be used as dry goods
- Does Python have a, = operator?
- Go through the string common sense in Python
- Fanwai 4 Handling of mouse events and solutions to common problems in Python opencv
- Summary of common functions for processing strings in Python
- When writing Python scripts, be sure to add this
- Python web crawler - Fundamentals (1)
- Pandas handles duplicate values
- Python notes (23): regular module
- Python crawlers are slow? Concurrent programming to understand it
- Parameter passing of Python function
- Stroke tuple in Python
- Talk about ordinary functions and higher-order functions in Python
- [Python data acquisition] page image crawling and saving
- [Python data collection] selenium automated test framework
- Talk about function passing and other supplements in Python
- Python programming simulation poker game
- leetcode 160. Intersection of Two Linked Lists （python）
- Python crawler actual combat, requests module, python to grab the beautiful wallpaper of a station
- Fanwai 5 Detailed description of slider in Python opencv and solutions to common problems