A simpler app testing tool than appium

A simpler app testing tool than appium!

One, the scene

In the wild era of app testing, it is very troublesome to automate app testing.

If Zhang Dafang wants to do Android automated testing, he must first learn Java.

Because Android automated testing can't get around the automated testing framework developed by Google itself, Zhang Dapang started to learn java and started to use UiAutomator to do automated testing.

Two weeks later, Zhang Dafang began to complain to Brother Wang:

A simpler app testing tool than appium

 

When Wang Ge looked at his code, the demo hadn't even started, and if he let him play, the company went bankrupt.

So Wang Ge recommended a tool called appium to Zhang Dafang. This tool is strong in cross-platform, cross-language, and open source.

Zhang Dafang had learned python for half a month before, so this problem shouldn't be a big deal.

After a day, Zhang Dafang rushed over happily and said happily that the process ran through.

Appium is a good thing, but there is a downside. Finding elements on the app through code often involves nesting java code and bringing a long list of device information.

Brother Wang also recommended a tool to Zhang Dapang, this tool is called python uiautomator.

It can install an http rpc service on the mobile phone, and you can use other languages ​​as a client to remotely call the interface of uiautomator.

This library solves 2 problems of the original uiautomator:

◆ Must know Java code

◆ The script can only be run after being transferred to the device

His schematic is similar to this:

A simpler app testing tool than appium

 

Compared with appium, the API packaged by this tool is more concise and more efficient to use.

Zhang Dapang immediately went back to study it, and the process ran through in 15 minutes. He asked Brother Wang to rub the crayfish on the same day.

With such a useful tool, Zhang Dafang hurriedly came back to write notes.

Two, installation

The installation should not be too simple, just one line of command.

Compared to the various dependencies that appium has to install, it's not too happy.

After the installation is complete, connect the mobile phone, enter the adb devices command, confirm that the mobile phone is connected successfully, and complete it easily.

A simpler app testing tool than appium

 

Three, quick use

How to measure by hand, the process of this tool is exactly the same, saves worry and effort, and there is no extra line of code.

When using appium, Zhang Dafang didn't know how many brain cells were consumed in order to write long desired capabilities.

1. Connect the device; 2. Start the app; 3. Position the element; 4. Operate the element; 5. Close the app.

A simpler app testing tool than appium

 

Compare the appium code of the same version:


To make a simple comparison, the python version of uiautomator has the following advantages:

◆ When connecting to a mobile phone, you can save a lot of information

◆ The element positioning directly uses the more elegant __call__() mechanism, without the need to adjust the function name, but directly completes the element positioning in the form of keyword parameters.

◆ Using app as a management unit (session), there will be greater flexibility.

◆ This does not include more flexible waiting and watcher mechanisms.

Fourth, element positioning

Use the weditor tool to view element positioning:

For more convenient element positioning, you can use weditor to assist in obtaining element positioning expressions. If you don't want to use it, you can also use native Android auxiliary tools such as uiautomatorviewer.

Install weditor, you know pip install weditor.

After the installation is complete, enter weditor from the command line to start with one key, and the graphical interface will pop up directly.

A simpler app testing tool than appium

 

The advantages of weditor are:

◆ Can manage multiple devices at the same time;

◆ Operate the phone directly on the debugging interface, no need to move the phone with the other hand;

◆ Automatically generate uiautotor code.

Five, summary

This article introduces the very simple use of uiautomator and summarizes its advantages:

◆ You can experience the "happiness" of native testing without knowing Java;

◆ The api package is extremely simple and conforms to the elegant character of python;

◆ Get started quickly, you can have fun with a little understanding of python.

Stop talking, such a useful tool, I want to go back and eat it quickly.

 

Recommend a software testing learning exchange group: 785128166, there are shared videos, interview guidance, test materials, mind maps, and videos in the group. They are all dry goods, you can download and watch. Mainly share test foundation, interface test, performance test, automated test, TestOps architecture, Jmeter, LoadRunner, Fiddler, MySql, Linux, resume optimization, interview skills, and actual video data of large-scale test projects. Use every minute and every second of your time to learn to improve yourself, and don't use "no time" to conceal your mental laziness! Try hard while you are young, and give your future self an explanation!

Public number: Programmer Erhei, after paying attention, you can receive a large amount of learning materials for free.

Good things should be shared with friends
 

 

Guess you like

Origin blog.csdn.net/m0_52668874/article/details/114645440