Uiautomator Learning Essays

Source: Internet
Author: User

1. After the Uiautomator environment is set up, it can be used formally, and the specific operation of building and running in Eclipse is as follows:

(1) Create a project in Eclipse (Java project).
(2) Next->libraries->add Library, add junit libraries.
(3) Add External JARs:
Add the Android.jar and Uiautomator.jar below the android-sdk\platforms\android-17\.
(4) Add Class in SRC
(5) Find the SDK ID:
CMD into the \android-sdk\tools\ directory, run the command:
Android List
(6) Create a build file
Under the \android-sdk\tools\ directory, run the command:
Android Create Uitest-project-n <name>-T <android-sdk-ID>-P <path>
Like what:
Android Create Uitest-project-n autorunner-t 60-p E:\workspace\AutoRunner
The above name is the name of the jar package to be generated in the future, can be defined by itself, Android-sdk-id is the above 6;
Path is the route to Eclipse's new project, and after the command is run, the Build.xml file is generated in the project's root directory. If not generated, check the steps above.
(7) Compile build jar
CMD enters the project catalog and then runs the ant build, which builds the jar using ant compilation.
The generated jar will be in the bin directory.
(8) Push and run jar
ADB push <jar file path > data/local/tmp
adb shell uiautomator runtest <jar file name >-C < class name in project, including package name >
Like what:
ADB push E:\workspace\AutoRunner\bin\AutoRunner.jar data/local/tmp
adb shell uiautomator runtest autorunner.jar-c com. Runner
Then you can see that the phone will follow the steps in runner automatically.

2. Cannot get control problem in Chinese
Modify the file encoding format of the project in Eclipse, right-click the project->properties->resource->text file encoding from GBK to UTF-8, and recompile the project to run.

3, the Uiautomator method is the method name contains the method of test, if there is no method in the class name contains test, it will fail, if there are multiple names containing the test method, then these methods will be executed sequentially.

Uiautomator Learning Essays

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.