There's always been a wish to use Python to do an Android automated function test, in one step, before using Monkeyrunner, but found that the use of the control ID is very limited, especially the content of the ID is not easy to distinguish
With Repeatability, and later found Uiautomator can Resorceid, text, PackageName and other elements to locate, but also found Xiaochong the great god about Uiautomator package, links are as follows:
Https://github.com/xiaocong/uiautomator
As a small white, all this needs groping, after overcoming the problem of installing the Uiautormator package, and card in the start of the application of the problem, before the use of Monkeyrunner startup application using the following code:
From Com.android.monkeyrunner import Monkeyrunner,monkeydevice,monkeyimage
Package = ' Com.android.settings '
Activity = '/. Settings '
Runcomponent = package + activity
Device.startactivity (component = runcomponent)
is also my ignorance, tried for a long time, finally found the ADB shell am start package name/activity started, to set the application for example, the code is as follows
Import OS
Os.system ("adb shell am start-n com.android.settings/.") Settings ")
The results of the operation are as follows:
starting:intent {cmp=com.android.settings/. Settings}
0
Successfully enter the settings application interface, then you can try something else you want to do
Of course it just solves the problem I'm running on my PC, and when I look up the problem, I notice that Uiautomator is ultimately going to compile the jar file into a virtual environment in Android to execute the command, but there's no adb inside Android.
Environment, the ADB command will fail and must find a way to operate on Android
To make a memo, I hope I can go further and farther on this road
Come on.