“This is the first day of my participation in the Gwen Challenge in November. Check out the details: The last Gwen Challenge in 2021”

preface

The author has opened three paid columns in other technical forums, and the monthly average profit has been about 100 since the opening. From the standpoint of the author, I feel a little flattered, but from the standpoint of the readers, there are some shortcomings. First, the directory structure is not systematic enough, and it feels a little mixed up. Second, the content is not clear enough, some are full of code, and some concepts are not thoroughly explained. And then the nuggets operation bosses pulled to nuggets development, abandoned, and no time to optimize, the author is also deeply upset, a little live up to the fans wrong love; Take this nuggets operation activities, recomb, although nuggets can not be converted into cash, but the monthly reward is rich ah.

introduce

From the author’s testing position itself, no matter in the well-known technical forum or circle itself, it seems a little insignificant; Therefore, the author also hopes to show himself through such a platform. Before the author engaged in line QC (JQE), embedded software testing (partial hardware), game testing, OA system (Internet), credit card system testing (financial), P2P software testing (officially entered the Internet software industry) and so on industry, post level it also from step by step to manage post (well, is take the technical route). Although there is still a long way to go (there is also a certain chance), no one should be a stumbling block to the author’s progress. Come on, middle-aged uncle.

Interface automation test

There are a few things you should know before you build a framework

What is an interface test

Interface test is a test to test the indirect interface of a system component. Interface testing is mainly used to detect the interaction points between external systems and internal subsystems. The focus of the test is to check the data exchange, transfer and control management process, as well as the logical interdependence between systems.

— Baidu Baike

Why Python

Why not Java or some other programming language? In fact, this wave is the online training institutions with fire, under the guise of 0 basis, easy to learn, easy to start with ‘cheat’ in a group of lost in the testing road lambs, but the fact is also so; Python does have the advantage of being more than adequate for interface /UI automation testing. Don’t believe it? You’ll know it when you start learning. Listen to it a hundred times and fuck it once.

What is automated testing

The purpose of this concept is to save resources and improve efficiency, which has become the most eye-catching high-frequency word in online testing training in recent years. Even those who go out to find a test position are embarrassed to go out for an interview if they don’t know about automated testing. Take a look at baidu Baike’s definition:

Automated testing is the process of converting human-driven testing behavior into machine execution. Typically, after a test case is designed and reviewed, the tester performs the test step by step according to the procedures described in the test case to get a comparison of the actual results with the expected results. In this process, in order to save manpower, time or hardware resources, improve the efficiency of testing, it introduced the concept of automated testing.

How to learn interface automation testing well

First of all, you need to know how to do interface testing. Whether you use tools or code, the principle is the same. And then tools to achieve a set of interface automation test program, and finally to code again! You might ask, why don’t you just code it? B: well… Starting from the introduction to the test, not everyone has a precise career planning, for example, the author, most of the automation technology are introduced by tool, which is most of the test of the status quo of practitioners at first heard that easy introduction to the test, high salary (compared to other industries), can even understand rushed into doing little more money, so really? A few years later, the divergence became more pronounced. (Well, the author didn’t start automating until seven years later, so it’s a shame.) The author also often proclaims that first a tool automation test solution, and then coding to implement another one, is somewhat fulfilling the core functionality of the tool, even if there is no UI.

Environment set up

To do a good job, you must first sharpen its tools, this is the environment, do not talk about any code and implementation logic

Installation of the Python environment

Choose python3.5 or later. Don’t ask why it’s not PYTHON 2. Ask python4

  • Before Python development, we used to use a virtual development environment for ease of migration and isolation.
    • Python -m env /path Second, choose other virtual environment tools; Three is Anaconda; Select demo later
    • For example, in The Win system, open the CMD window and enter python -v

You can see the current Python version: Python 3.10.0

IDE development tool installation

Python has its own proprietary development tools, such as Pycharm, which is available in two versions, enterprise and community

  • Radish cabbage each love, the author loves to use Eclipse, because the author will be semi-skilled Java, so in Eclipse development more handy.
  • Install Pydev for Eclipse.

In the Eclipse help, install new software, click ADD Pydev name input, link address input: pydev.org/updates then select PyDev:dl.bintray.com/fabioz/pyde… I don’t have to choose the other one. You can download it, and then confirm step by step as you go down.

After the installation is complete, restart Eclipse to take effect.

  • Tips: The eclipse/PyDev version mapping is recommended for beginners to use Pycharm.
The programmer’s first program Hello World.
  • Create a Python project in Eclipse, create the helloworld.py file, and type:
print("Hello World!")
Copy the code

Right click to execute, console output: Hello World!

  • Enter the ipython interface on CMD and print(“Hello World!” ) enter:

  • After entering the code in the first method, go to the CMD command window, go to the project directory, and execute python helloworld.py. The result is as follows:

PIP tools

This is not a problem for the environment itself. If you need to do interface testing, it may not be enough. You need to rely on python third-party libraries to do interface testing, so PIP installation tool is useful, just like NPM for Node.

  • PIP install requests You can specify install version requests==2.4.3, which is the latest install by default

Requests are the primary tool for interface testing

  • Use effect demonstration:
import requests

res=requests.get("http://www.baidu.com")

print(res.text)
Copy the code

Request Baidu url to get the result is its source code, here is not posted

conclusion

At this point, the Interface test Python development environment is deployed.

Knock on the blackboard, knock on the blackboard, knock on the blackboard!!

Pay attention, here’s the point. In practice, there may be incompatibations between the dependency library version and the Python version, but don’t panic. It is recommended to use a stable version between the two. There is also a problem with virtual environments. Write at the end, wish you all a happy learning interface automation test!!