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

Get basic information about the iOS device from the Airtest script, such as uUID, width and height of the device, device resolution, etc. The second one uses a mix of Airtest and POCO scripts to test the iOS calculator native app.

Let’s take a look

Obtain basic information about iOS devices

1. Obtain the UUID of the device
dev = device()
dev.uuid
Copy the code
2. Obtain the length and width of the device: window_size
dev = device()
dev.window_size()
Copy the code
3. Obtain the current device orientation: Orientation
dev = device()
dev.orientation
Copy the code
4. Obtain device details: display_info
dev = device()
dev.display_info
Copy the code
5. Obtain the rendering resolution of the device: get_render_resolution
dev = device()
dev.get_render_resolution()
Copy the code
6. Obtain the current device resolution: get_current_resolution
dev = device()
dev.get_current_resolution()
Copy the code
7. Obtain the device IP address: get_ip_address
dev = device()
dev.get_ip_address()
Copy the code
8. Obtain device status: device_status
dev = device()
dev.device_status()
Copy the code
9. Operation: Displays basic information about iOS devices

Example code is as follows:

The running results are as follows:

To display basic device information in a report, you can use the log() interface:

Calculator case

1. Initialize the script

Special attention:

The function of the script in the first sentence is to declare the encoding. Do not omit it, otherwise it is easy to generate coding errors during the script operation.

(2) PoCO initialization should be done after the device connection script, especially when running such scripts without the IDE. It is necessary to pay more attention to the initialization order of POCO. If the poCO is initialized for the game project rather than the native app, it is also important to note that the POCO must be initialized after the device is connected and the project is started.

2. Test clicking on the picture

Screenshot tips:

① There are few feature points in pure numbers or text screenshots, so it is best to take frame screenshots when capturing such pictures;

② If the target screenshot only contains pure numbers or text without borders, it can be considered to appropriately increase the range of screenshots and add feature points of screenshots.

3. Test double-clicking on an image

Special attention:

Double click(Template(…)) )

A try-except method in which a script error does not affect the execution of the program

4. The assertion

summary

Today’s content is very easy, interested students can pick up the iOS device at hand quickly test, deepen the impression.


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 ~