This article is from the official account of the project: “AirtestProject” Copyright notice: It is allowed to be reproduced, but the original link must be retained. Do not use it for commercial or illegal purposes

preface

Today, I would like to talk about the problem that clicking does not take effect. I often hear some students in the q&A group say: why does my code execute but there is no clicking action? Or, why can’t I click on the screen when I connect to the device using the IDE?

Let’s look at the following, when students encounter a variety of “click does not take effect”, how to investigate.

“Click does not take effect” troubleshooting method

1. Check whether the latest version is used

① Use the environment of the AirtestIDE

Check the IDE options to see if the python.exe path is customized. If not, check the AirtestIDE to see if it is the latest version. If not, update it to the latest version.

② The native Python environment is used

If the path of python.exe is customized, it indicates that the local Python environment of the AirtestIDE is not being used. Then check whether the airtest library in the customized Python environment is of the latest version. Please also update the airtest library to the latest version.

We can run PIP List from the command line (especially if multiple Python environments exist locally) to see which one we are using:

In the same case when you run a command line or any other Python editor, you need to check that the current runtime environment has the latest version of the Airtest library.

2. Try in the IDE to see if you can click the phone screen

1) can click

Rule out the problem of mobile phone Settings.

② Cannot be clicked

Pay special attention to some brand mobile phone need to open the “allow the simulation click position” such options, the details to view the official document: airtest.doc.io.netease.com/IDEdocs/dev… .

3. Write a separate script to run only the statement that does not take effect and generate a report after running it

Here’s how to use the minimum reproducible script to eliminate interference from other code and locate the problem more quickly:

① An error occurs in the log view window

If there is an error like Picture XXX not found in the screen, it means that the screenshot identification failed, we need to re-screenshot; For example, take screenshots with more obvious features to reduce the mixing of redundant background and so on. On how to improve the compatibility of screenshots, we also wrote in the previous tweet “write 10000 Airtest screenshots summed up by screenshots experience, quickly collect!” There is a detailed introduction, students who need to go directly to read.

If an error message such as PocoNoSuchNodeException: Cannot find any Visible node by XXX is displayed, the control fails to be searched. You need to check whether the control is located correctly and whether the control exists on the current page.

② No error was reported, but it was found in the wrong position after checking the report

More commonly seen in screenshots:

In one case, there are multiple screenshots of the same type on the current page, but the actual running time does not click on your real target. In this case, you can help you to locate your real target by partially recognizing the image or adjusting the target_pos of the screenshot.

In another case, irrelevant and wrong targets are identified. It may be that the threshold value of the image is low and wrong results are mixed in. You can try to adjust the threshold value to filter the wrong results.

③ No error was reported, but it was found in the report that the click had a certain position deviation

Common in Poco control click scripts:

First of all, we can use the IDE auxiliary window to retrieve the control function, move the mouse over the corresponding control, to see whether the lock control frame is offset, such as offset, we can correct some offset, or remove the virtual button bar of the phone to solve the problem, see our official tutorial document: Airtest.doc.io.netease.com/IDEdocs/dev… .

④ After checking the report, I found that the screen was not loaded and clicked

When the screen is not fully loaded or stable, and we click immediately, it is likely that the click actually took place, but the app did not respond to the click.

At this point, we can add enough sleep() before clicking to ensure that our application is stable before further clicking.

summary

Finally, we provide a “click does not take effect” self-check flow chart, students can save the need to check oh!


AirtestIDE download: airtest.netease.com/ Airtest tutorial website: airtest.doc.io.netease.com/ build enterprise private cloud service: airlab.163.com/b2b

Official Q group: 654700783

Ah, so serious all see here, help in the left side of the article click on the likes and favorites, give me a support, ash often thank ~