? 3.1 ADB Tools explained
3.1.1 What is ADB?
We do not explain the official language of the translation, to tell you a well-understood argument, adb I understand that he is the computer and mobile phone connection bridge. This connection is not charging the connection, everyone do not confuse, said he is a debugging tool, may be more appropriate.
What is the role of 3.1.2 adb?
Just said he is a computer and mobile phone connection bridge, we can operate through the ADB mobile phone, can manage mobile phones. Maybe you said the phone here includes the simulator? The answer is yes.
3.1.3 How to use adb?
We can perform the corresponding operation by entering the ADB command directly at the terminal. The most common thing we use during testing is to see what Android devices are connected. Probably tidy up a bit of the usual:
1. ADB devices view connected Android devices
2, adb install baidu.apk This is the installation of applications, if we are currently connected to more than one Android machine, the use of this command is not possible, this time we need to specify the device: Adb-s install baidu.apk, Here,-S refers to the device information, which is the device information that is viewed through ADB devices.
3, adb uninstall baidu.apk This is the uninstall application
4, ADB connect 127.0.0.1:62001 This command everyone must remember, connect the specified device information, here the device refers to the virtual machine, if we use the virtual machine is not official, is domestic daily, night watchman and so on virtual machine you need to use the Connect command connection, The port number here is not necessarily 6555, which needs to be decided by the brand of your simulator. Just learn if it is not possible or recommend using the real machine, just to open the ADB debugging just fine.
3.2 Uiautomatorviewer Tool Explanation
Uiautomatorviewer is a positioning tool, whether under Windows or Mac can be used, he in your ANDROIDSDK directory under the Tools directory, I just according to my to everyone, the following to configure a picture, more intuitive:
Can look in my directory, in the last tools directory there is a uiautomatorviewer file, we need to hit the directory directly in the current directory command will open our Location tool interface, below we directly look at our:
Here's a question to keep in mind, because I'm using a homegrown simulator, so I need ADB connect 127.0.0.1:xxxx after starting the simulator, but before that you still need to open the developer options in the simulator, because only after the connection is established can you use the locator tool, Otherwise it will be an error.
After we open the Locator tool, the simulator directly clicks the Red circled button (get current screen) in the upper left corner of the positioning tool Uiautomatorviewer automatically gets the page that is opened by the current emulator.
The leftmost area is the captured emulator page, where the mouse moves over the element you are looking for, and on the right side of the entire area is a layout structure of the current object that clearly sees what layout he is using. The lower right corner of the area is the property value of the object we need to locate.
In the lower right corner of the property I made a distinction, the red part on the left is the property name, the right is the property value, when I select a control or object on the top of the following properties will change, in the property is mainly: index, text, Resource-id, class, package , Content-desc, these properties and attribute values they correspond to the page element we are going to talk about, the main thing we do automation is to interact with these properties. There is a problem here: The Text property of this page property is positioned for the name, but in the new version of Appium has removed the name of the location, so everyone pay attention to this problem, then if the error is not anxious.
3.3 Package and activity commentary
In the collation of this knowledge is actually very tangled whether to say this knowledge point, but weigh the decision or explain it, or the following chapters on the automation may be some of the basic readers will have some inexplicable.
What is a package? We all know the meaning of the package, in fact, it is true, if you have to understand this is also true, but in our app is unique, just like your ID number. When we do app automation, we need to know his package, we know the package so we know which app we need to automate, and now we can understand what the package means?
What is activity? The official explanation for activity is one of the most basic and most common components of Android build. Do you think it's so confusing to see this? So, he also has an inaccurate statement, is to interact with the user, each time the user opens the app to operate the time will find in the constant jump page, in fact, each page is an activity. We got the package for the app when we were automating it, but we couldn't start it because we didn't tell us which activity to do, so at this point we need to talk about the activity written to the startup parameter when the app starts, It doesn't work if you pass in a different page.
3.4 Package and Activity acquisition
I've talked so much before, but I don't know how to get it, right. Haha, only know the role but do not know the source of this is not a place to do.
First of all, the way to get the package and activity, on the internet said there are many kinds of, here I only tell you what we commonly used.
1, because automation is generally their own application, so this must be their own company, then you take this is not simple? Just look for the development to be on the line.
2, Appium has the interface of the client, this file you choose the path of the APK in the settings after the system will automatically show the information about the APK is below, so it is very simple, but sad that he can not copy, you write in the program you still need you to a letter to tap
3, through the Android SDK tool, there is a tool in the SDK, called AAPT, we can directly through this tool, in the command line input: AAPT dump badging xxxx.apk, After this xxx.apk file is the absolute path of our aok, after typing then you can display the relevant information, you can find in the inside, PackageName, lanuchactivity the two word end, one in the beginning 1, 2 line one in the middle part.
Appium Python automated Test series Android Knowledge (iii)