Airtest

Latest version: v1.3.4

Safety actively analyzes 629855 Python packages for vulnerabilities to keep your Python projects secure.

Scan your dependencies

Page 5 of 5

1.0

>>> print(TIDevice.list_app(udid, "system"))

1.0.0

>>> print(TIDevice.list_wda(udid))
['com.test.WebDriverAgentRunner.xctrunner']

>>> print(TIDevice.device_info(udid))
{'productVersion': '12.4.8', 'productType': 'iPhone7,2', 'modelNumber': 'MG472', 'serialNumber': 'DNPNW6EJG5MN', 'timeZone': 'Asia/Shanghai', 'uniqueDeviceID': '10da21b9091f799891557004e4105ebab3416cb9', 'marketName': 'iPhone 6'}

>>> TIDevice.start_app(udid, "com.apple.mobilesafari")

>>> TIDevice.stop_app(udid, "com.apple.mobilesafari")

>>> print(TIDevice.ps(udid))
[ {'pid': 215, 'name': 'MobileMail', 'bundle_id': 'com.apple.mobilemail', 'display_name': 'MobileMail'}]

>>> print(TIDevice.ps_wda(udid))
['com.test.WebDriverAgentRunner.xctrunner']



The execution example of the `TIDevice.xctest` interface is as follows:

import threading
wda_bundle_id = TIDevice.list_wda(udid)[0]
Create a thread to execute xctest
t = threading.Thread(target=TIDevice.xctest, args=(udid, wda_bundle_id), daemon=True)
t. start()
time. sleep(5)
ps_wda = TIDevice.ps_wda(udid)
print(ps_wda)
time. sleep(5)
Terminate thread
t.join(timeout=3)



Changes to the using interface

The function of the `using` interface is to support another script to be referenced in the script, and at the same time, it can also allow airtest to correctly read the image path in other scripts.

Suppose the directory structure is as follows:


demo/
foo/
bar.air
baz.air
main.py


If we want to reference `foo/bar.air` and `baz.air` in main.py, we can set the project root path to `ST.PROJECT_ROOT`, or make sure the project root path is the current working directory:


main.py
from airtest.core.api import *
ST.PROJECT_ROOT = r"D:\demo" This line can be ignored if it is the current working directory
using("foo/bar. air")
using("baz. air")


If we wanted to reference `baz.air` in `foo/bar.air`, we could write:


foo/bar.air
from airtest.core.api import *
using("../baz.air")


New error type NoDeviceError

If no device is currently connected, but some interfaces that need to be connected to the device are called, an exception will be thrown: `NoDeviceError("No devices added.")`

Other changes

1. When the airtest script raises an assert exception, the exit code is 20 to distinguish it from other errors
2. Updated Yosemite.apk and fixed some stability issues
3. The new interface `set_focus` on the windows platform has the same function as the original `set_foreground`

Page 5 of 5

© 2024 Safety CLI Cybersecurity Inc. All Rights Reserved.