How to create automated testing pit in Python – Python automation

python-automation

 As a software testing industry, at the moment, if you learn automation well, you are not afraid of wherever you go for an interview.

That said, but you want to leave work early, automate testing to liberate labor, improve efficiency, and allow program scripts to “take-off” without guardsIf your code or script falls into a pit, you think you can leave work early?

Chances are, you might not even be as good as someone else doing functional testing. It’s been a long time since someone else has tested a function, and your automation script reported a bunch of errors. I don’t know the cause of this error. Naturally, your automation cannot be done, and the value of automation cannot be reflected. Therefore, I will explain some practical cases for some pits that are easy to encounter in our Python automated testingBefore talking about these pits, let me share with you my understanding of the concept of automated testing.

Before doing automated testing, we have to think about a problem. Automation does not mean that you can write a simple automation script and you can implement it. You need to have a plan, go slowly in advance landing.

I summarized a few points:

1. According to business characteristics, choose an automated test plan.

⒉. Confirm the scope and granularity of automation based on business focus.

3. According to the scope of automated test cases, select the implementation framework and language.

4. According to the purpose of the use case, select an execution strategy.

(1) You are in a company, what does your product look like? According to the business characteristics of your product, you choose to determine an automated test plan. This is very important. For example, your company’s main business feature is the database or back-end content (some products focus on the front-end interface)

So you have to choose a solution, whether to do UI automation or interface automation first.


Automation is mainly divided into two major parts: UI and interface

UI: Selenium

app:Appium / uiautomator2/airtest

Interface: Http Postman Requests

WebSockets/Dubbo

For example, if you do UI automation first, you have determined this plan, and then you can confirm the automation coverage and granularity according to the business focus.

For example, if your company does UI automation, you can’t write automation test cases while looking at a page. From logging in to registering to forget your password, etc., you don’t need everything to cover. According to a core process of your company, which ones must be covered and which ones are technically difficult, you can put them in the second period.

Then according to this scope and plan, you choose the appropriate testing framework and language. For example, if you do UI automation, it is recommended that you use Selenium as your preferred framework. Of course, if you are an APP (Android), you are recommended to use uiautomator2. This is a third-party library of Python. Its environment dependency is very simple. Of course, the most mainstream on the market is Appium, its environment depends on complexity, its only advantage may be to support IOS, it is cross-platform. If you are making games, I recommend you to use the artist

How to exchange experience in software testing, interface, automation, performance testing, test development, and interviews. If you are interested, you can 1079636098. The group will issue free information links from time to time. This information is collected and organized from various technical websites. If you have good learning materials, you can chat with me privately, and I will indicate the source Share it with everyone afterward.

Interface: Http Postman

Most companies now use the HTTP interface protocol. Tools can use Postman

If you interface automation, use a library of Python, Requests

Why is Python so easy to use? It has a very rich third-party library. It is ready to use, and it contains many good APIs

Of course, there are WebSockets/Dubbo, like this type of protocol interface.

A keyword is indispensable for testing, which is automation. Now whether you are in a company or you go to an interview, when you talk to your peers about a keyword, it must be automation. Even if you are interviewing for a feature, not for automation, the interviewer will ask you about the automation content. Because automation has been a must-have skill in recent years, rather than a little automation is a plus.

In the past few years, everyone knows that tools such as QTP and LoadRunner are more commonly used. After all, due to historical reasons, everyone first came into contact with functional tests, so you have to determine the appropriate framework. No matter which protocol interface, it can be done with Python. Python is a language and can be used to drive any of the above frameworks. Of course, there are other options, such as JAVA, JS, etc.

Of course, the most suitable for friends who are just learning automation may still be Python. And Python can do a lot of things. For example, if your company wants to do a crawler, you need to do some data sorting, and Excel table operations. If you are outside the scope of the company’s work, you can help these things, then this is all your Plus points, your value will be reflected. Looking back at my first job, my first contribution to the company at the time was that I wrote a crawler script in Python and helped our after-sales department collect hundreds of thousands of data. Python provides a very convenient library for crawling.

Then we assume that the previous content is determined, we can choose the execution strategy according to some uses of the automated test case.

You may do verification before going online, returning after going online, triggering verification (when certain businesses trigger this function only under certain conditions), continuous integration.

Trigger verification: To give a very simple example, my ID card expires in 2020 this year, so many bound bank cards, will the bank prompt you to change it in time ?

Common pit

Driver is not found: Message: chrome driver’ executable needs to be in PATH

Element not found: The script reports “NoSuchElementException: Unable to find element”, or “Located, unable to operate, click invalid”