To say that Android automation, that really toss me, from the early Monkeyrunner, to later Robotium, and then to the latest uiautomator, each have various problems, in short, the price is not high enough, not suitable for my use of the scene. So reluctant to put the results of research into practice, have been waiting. This year's adaptation problem is becoming more prominent, no automation, the return should be dead.
So the final study than to Instrumetation and Uiautomator, finally determined the Uiautomator plan, in fact, is also reluctant to, but finally can be achieved. First prepare the script, batch modified all the layout files, add the ContentDescription property, a little dynamic generated layout, can be added in the development of the code, the time to submit to SVN, and then a new module, are required to increase the property, Submit to the test to add an automated test module on it.
However, through the SDK Tools directory under the Uiautomatorviewer.bat (Administrator permissions to run), to view the interface elements, and then refer to and operate, one needs to develop a strong cooperation, and the other is to write a little bit by themselves, three is to compile into a jar package, Push to the phone to run, which means only log brute force debugging.
Twists and turns, there was a project to find ways to test C # WPF, after the matter, found that Ranorex can also test iOS and Android programs, exultation. So I tried it and found that it was great to be able to identify, record and replay the same objects as the most traditional automated test tools. (after the test, found not suitable for me, because Ranorex and robotium, can not cross-application, can only be used back to uiautomator solution)
The whole step is basically:
1. Instrument source code, compile a measurable version (this I go back to write a chapter, how to do instrument source);
2. Create a test project for Android;
3. Connect the mobile phone, the phone will install a service;
4. Deploy the pre-compiled testable apk to the phone;
5. Recording, playback.
This is a good thing to use the instrument, that is, he is not from a lone apk outside, but directly from the source hook, that to access to the program of anything can be. This will not worry about the day Google closed the door, instrumentation but his own things.
First of all, create a project:
001.png
002.png
Module and advanced can create a CMD console program, you can create a module library of tests, you can also create a form program, I chose the default Testsuite
003.png
It's like this after you've created it.
No matter 3,721, start recording directly:
004.png
005.png
Here is the source of the APK is processed, in fact, deploy when the tick on the instrument on it, but I would like to talk about instrument details it. Reference: Hand teach you ranorex_android source instrument
006.png
Tip JRE1.6 not found:
Fill in the JRE directory:
C:\xxx\android\Java\jdk1.6.0_03\jre
Casually say: The JRE is the Java program running environment, JDK is you do Java development of the set of things.
007.png
Error:
008.png
1. Check if the APK is confusing (obfuscated)
2. Must use Api8 above, that is, sdk2.2 or above version;
3. Is there an instrumented version installed on the phone?
In turn, check found that there is no problem, look carefully, I pour, how the phone connection is a fork, so remove the phone to add again, so it's done.
So do not think that the choice of equipment on the right, you should always pay attention to check the status of the device is the hook or fork:
009.png
A service will start on the phone before the deploy APK:
010.png
This looks like the installation was successful:
011.png
Click on the test program in the service interface and you'll see a toast tip: Ranorex connected
Open the View spy on Ranorex
012.png
013.png
All the objects are identified, and to know the citation, just find the object and click Track.
And then in
014.png
In the object library (this example is TandroidRepository.cs) you can see the referenced interface element, recording the operation in Recording1.cs (the header section of this file emphasizes://Do not MODIFY this file! It is regenerated by the designer. ), but it doesn't matter, and Recording1.UserCode.cs, your code can be written here, copy the recorded code to change the bar can be used.
Well, this Ranorex project and Android example, I have to pack together to provide you with the download to try it.
Teach you ranorex_android. The first example of automated testing