http://www.jianshu.com/p/7718860ec657 2016.07.25 20:59 words 3675 Android Uiautomator Brief introduction of the--------------------------------------------------------------------------------Uiautomator is Google launched , a tool for UI Automation testing, i.e., a normal manual test, click on each control element to see if the output is as expected. For example, the login interface to enter the correct and
How does Ant package third-party JAR packages used by the UIAutomator project, antuiautomator
This article mainly describes the various problems encountered in the normal packaging method when a third-party Jar package is referenced in the UIAutomator project, as well as the Final Solution ideas and methods.1. Origin
The jar package of the unit test framework hamcrest is referenced in my example project. Th
in the Bin directory.4.8. Push and run the jarADB push adb shell uiautomator runtest Like what:ADB push E:\workspace\AutoRunner\bin\AutoRunner.jar data/local/tmpadb shell uiautomator runtest autorunner.jar-c com. RunnerThen you can see that the phone will follow the steps in runner automatically. The effect is to go to the settings menu and then go to the language and input menuFive, Code AnalysisWe introd
In the previous article "start and run of uiautomator source code analysis", we described the whole process of uitautomator from running the command line to loading the test cases to run the test, during the process, we also described the importance of the uiautomatorbridge class, saying that it is equivalent to the proxy of uiautomation (we all know that uiautomation is connected through uiautomation and accessibilityservice and then gets interface s
Android Automated test-uiautomator Environment setupFirst, the Environment preparation 1. Install the Android SDK and configure the environment variables2. Install Android Studio, domestic access to the official website is limited, if not downloaded, you can go to my Baidu cloud disk download:Https://pan.baidu.com/s/1bpq5wK3This cloud disk has Uiautomator2-dependent jar packages that can be downloaded at the same time Second, the new Android Studio
[UiAutomator] the difference between using the instance and index methods in UiSelector to locate controls.
When you use UiAutomator to write test cases, the most common operation is the control query operation.
In UiSelector, there are two methods for locating controls: instance and index. So what are the differences between the two methods?
First, let's take a look at the official api description:
Instanc
In the first article:
Comparison of controls obtained by hierarchyviewer and uiautomatorviewer in android automated testing (1)
I said that an error will be reported when uiautomatorviewer obtains the dynamic interface. The error is as follows:
Today, when I learned uiautomator and used dumpWindowHierarchy () to obtain control information, I found that this method can obtain dynamic interface information. This makes up for the defect of uiautoma
Python+android+uiautomator the environment to buildPythonDownload the appropriate version of the system and install it, tick the path to add it when installingVerify: Open cmd input python under WindowsThe following interface appears to indicate successful installationAndroidDownload installation path: HTTP://TOOLS.ANDROID-STUDIO.ORG/INDEX.PHP/SDKDownload the installation JDK firstJDK Installation Documentation: http://jingyan.baidu.com/article/6dad50
Get coordinates and coordinates clickKnowledge related to coordinates:1) Phone screen coordinates: Upper left corner start to bottom right corner end2) DP: device independent pixels, such as 320 pixel display to 640 pixels to stretch one times3) point: Represents a dot (x, y), and the upper-left corner of the coordinate is always (0,0)Two, coordinate related API:
return value
Method name
Describe
Boolean
Click (int x, int y)
Use coordinates to tap
Method/Step
1In fact, the stop is very simple, just to end the process of monkey offHow to stop it?
2PS command to find the Uiautomator processOpen cmd Command Line windowInput:ADB Shell PS | grep MonkeyThe first number returned, which is the process number of the monkey
3The KILL command ends the process to continue typing:ADB shell kill [process number just found]End other processes as well, and other applications can also use this method
The various types of environment configurations that are configured in Uiautomator today are based on the documentation,Result input in cmd: ant-versionPage report ant is not an internal command, instant dumbfounded, I was not configured error Ah, the result and re-looked at the document, or not wrong, but after the input command, or always error;1. Configuration environment:New :( variable value in system variable depends on each person extracting th
compiling: ant, use the command line to open the project root directory and execute ant directly
Note the JAR package location information in the output results
Push file to Mobile: adb push
Run test: adb shell uiautomator runtest
-C
Test all the use cases under a class, Package_name.class_name
To test a specific method: Package_name.class_name#method_name
Multiple –c can be specified
[UiAutomator] usage of instance and index in UiSelector, instanceof usage
When you use UiAutomator to write test cases, the most common operation is the control query operation.
In UiSelector, there are two methods for locating controls: instance and index. So what are the differences between the two methods?
First, let's take a look at the official api description:
Instance (int instance ):Set the search c
of non-continuous integration is not automated, so here is the automation integration based on Jenkins, in fact, uiautomator do integration is very easy, just put the jar package in a fixed directory, and then the shell command execution is done.Then the scheduled task to choose their own, build a failed email alert here is set, above my custom exception class, when the console output my exception class, then will think not to pass, and then trigger
First, Hierarchyviewer:Pros: Intuitive access to information about UI layout design structures and various properties in a visual perspectiveCons: 1) Poor stability, there are some situations in which the probability of obtaining a certain control is not obtained.2) performance is not good, when using the Hierarchyviewer function test, get control and so on when the execution efficiency is very low, resulting in the entire test time use particularly long, consumption of debugging time3) Only use
case
Bundle
Getparams ()
Get Command line arguments
Uidevice
Getuidevice ()
Get Uidevice instances
void
Sleep (Long ms)
Sleep time
Inheritance method:Junit.framework.TestCaseJunit.framework.AssertJunit.framework.TestJava.lang.ObjectExceptionsCom.android.uiautomator.core.UiObjectNotFoundExeptionDescription: Uiselector did not match to any UI element when generating a test runPublic constructorsUiobjectnotfounde
and shape A way to determine whether an object exists, appears, or disappears:Example:Runtime.getruntime (). EXEC (AM start-n com.android.calculator2/com.android.calculator2.calculator); Turn on your computerUiObject AddObject = new UiObject (new Uiselector (). Text ("+)"); Computer interface "+" ObjectAddobject.waitforexists (10000);Summarize:1. After declaring the Uioject object, no matter whether the object exists or not there is no problem---first declare the object, after operation;2. Whe
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.