当前位置:网站首页>App automation and simple environment construction
App automation and simple environment construction
2022-07-24 10:38:00 【Gxy is working hard】
The content of this issue
1、 Install Simulator
2、 Verify that the simulation installation is successful ,adb You can use
3、 Connect the simulator .
4、 Learn to operate simulator commands after connection .
5、 Use these commands for simple automated testing .
app automation
- One . Let's popularize one Android knowledge
- Two . The software needed is
- 3、 ... and . Verify whether the installation is successful and connect the simulator
- Four . Learn to operate simulator commands after connection .
- 5、 ... and 、 Use these commands for simple automated testing .
One . Let's popularize one Android knowledge
1. Professional term
Android The term
The term (terminology), Also known as noun , It is a special term in various disciplines ,Android There are also some terms of their own
In daily development , And others Android Communication or consultation , These terms are used , The other party will understand what you want to express as soon as you hear it
The following table lists the terms used in daily development
Permissions and other program configuration files
| The term | explain |
|---|---|
| Dalvik | Android Unique virtual machine , and JVM Different ,Dalvik Virtual machine is very suitable for mobile terminals ! |
| AVD | (android virtual machine): Android virtual device , Android simulator |
| SDK | (software development kit) Software development kit , It's Android , A collection of tools for platform architecture, etc , Such as adb.exe |
| ADT | (android development tools) Android development tools |
| DDMS | (dalvik debug monitor service) Android debugging tools |
| adb | Android debug Bridge , stay SDK Of platform-tools Under the table of contents , A lot of function , Command line must |
| DX | Tools take .class convert to .dex file |
| AAPT | (android asset packing tool), Android resource packaging tool |
| R.java | from aapt Tools according to App The resource file in is automatically generated , It can be understood as a resource dictionary |
| AndroidManifest.xml | APP Package name + Component declaration + The minimum compatible version of the program + Configuration files of programs such as required permissions |
2. Installed architecture
← Android The platform architecture →
Testing process :
Two . The software needed is
link : mumu Simulator perhaps link : Night God Bloggers here have mumu The browser demonstrates
3、 ... and . Verify whether the installation is successful and connect the simulator
Verify whether the installation is successful
1、 open mumu,( Attention is to open your mumu Simulator software Not the catalog )
2、 find mumu Install under directory MuMu\emulator\nemu\vmonitor\bin Catalog
3、 Open in the current directory cmd, perform adb_server connect 127.0.0.1:7555, Start the connection , The following command is not easy to use without starting .
Bloggers here suggest that they have connected to
The installation is successful
Connect the simulator
1、 After the above steps Open one more cmd window
perform adb_server devices Command is enough .
or take adb_server.exe Copy and change the name to adb.exe (adb_server.exe In your bin In the catalog , You can make a copy Put it in bin Under the table of contents Renamed as adb.exe ) The original can be backed up
Re execution adb.exe devices. this Sentence is to check the connection Simulation equipment name .
So the connection is successful
Four . Learn to operate simulator commands after connection .
1. stay mumu Simulator's bin Under the table of contents perform cmd
Execute the following command
Installation command
adb install …apk( File name and directory ) install apk perhaps Adb install -r apk Overlay installation
Bloggers have already made three ask file 
give the result as follows 
ok!
Unload command
1. Need a new mobile phone stay bin In the catalog cmd Knock inside adb shell(adb We just bin Copy the modified name under the directory )
Here we have entered
And then tap cd /data/data, have a look There are so many software packages in Android , The package name is the reverse of the company domain name As shown in the figure 
2. Find the name of the file you want to uninstall
First ctrl+d sign out mobile phone
Enter the command adb uninstall packagename( Package name )
In this way, the uninstallation is successful
See all apps
Also in bin In the catalog cmd Enter the command adb shell pm list packages
It has been successful
View system applications
stay bin In the catalog cmd Enter the command adb shell pm list packages -s
It has also been successful
Check out third party apps
stay bin In the catalog cmd Enter the command adb shell pm list packages -3
a !
Check the application with a string in the package name
stay bin In the catalog cmd Enter the command
• adb shell pm list packages youdao
• adb shell pm list packages | grep youdao (findstr “youdao”)
If you are windows command Need to put grep youdao Switch to findstr “youdao”:
It has been successful
View front desk Activity Start Youdao Cloud notes
stay bin In the catalog cmd Enter the command
adb shell dumpsys activity activities | grep mFocusedActivity
If you are windows command Need to put grep Switch to findstr
It has also been successful
Use command start-up app: close app,
The startup class name has been found :com.youdao.note/.activity2.FirstUseIntroActivity
stay bin In the catalog cmd Enter the command
adb shell am start -n com.youdao.note/.activity2.FirstUseIntroActivity
You can see the page on the left It also succeeded
5、 ... and 、 Use these commands for simple automated testing .
The software needed is
1.Android Studio
link : Android Studio
Inside skd Try not to put the path in C disc Create an empty file on another disk The name cannot have Chinese or spaces After installation, check whether there is sdk
First step 
The second step 
We are not talking about mumu Simulator bin In the catalog adb_server.exe A copy is copied and modified as adb.exe Do you ; Next , I'm also going to sdk In the catalog adb.exe Replace with mumu Simulator's adb.exe And back up the original .

1 Is the original backup
2 yes hold mumu Simulator's adb.exe Copied over
Either of them can replace the other Just make sure that Two adb.exe Just keep the same version otherwise Can't start
The third step
Configure environment variables
stay In the computer Find the edit environment variable 
Create a new environment variable A variable called ANDROID_HOME Value is what you installed SDK route

In the selection of system variables path Click edit 
Edit the following variables to path
%ANDROID_HOME%\platform-tools;
%ANDROID_HOME%\cmdline-tools;
2.Appium Inspector
link : Appium Inspector
windows Download this 
After downloading, open Click on VIew Set up Chinese 
We configured Youdao cloud to start json
The blogger has written You can copy and paste
{
“appium:platformName”: “android”,
“appium:deviceName”:“127.0.0.1:7555”,
“appium:appPackage”: “com.youdao.note”,
“appium:appActivity”: “activity2.MainActivity”,
“appium:unicodeKeyboard”: true,
“appium:resetKeyboard”: true,
“appium:autoGrantPermissions”: true
}

json principle
{
desired_caps = {‘platformName’: ‘Android’, # Platform name
‘platformVersion’: ‘5.1.1’, # System version number
‘deviceName’: ‘127.0.0.1:62001’, # Equipment name . If it's a real machine , Generally in ’ Set up -> About mobile phone -> Equipment name ’ Check it out
‘appPackage’:‘com.youdao.calculator’, # apk The package name
‘appActivity’: ‘com.youdao.calculator.activities.MainActivity’ # activity name
}
Then click Save as in the lower right corner Just save it
Click the start session added at the bottom right
After successful connection The simulator will have this software 
Then I see on the simulator There is a cloud interface Now We can The operation is carried out through this detector 
3.Appium Server GUI
link : Appium Server GUI
Open... After downloading It looks like this 
And then we click Edit see jdk and sdk Whether the configuration is successful 
You can see that it has been set by default We don't need to modify
Close this window Click on start Sever function 
This is the page
link : mumu Simulator
There's nothing to say about this I also introduced
testing procedure
This test case is coordinates
1. We have installed the software And the configuration is completed
2. Launch link We talked about how to connect the simulator
The thing to remember here is Start the simulator first Connect again
3. Open software
start-up mumu Simulator !!! To start before starting the connection
start-up Appium Server GUI
start-up Appium Inspector With the cloud we configured before json Can
command
Click on adb shell input tap X Y
write in adb shell input text 123456
Recording screen adb shell screenrecord /sdcard/filename.mp4
Press... When you need to stop Ctrl-C, The default recording time and the maximum recording time are 180 second .
If you need to export to a computer :adb pull /sdcard/filename.mp4
Screen capture : adb shell screencap -p /sdcard/sc.png
take png File export to computer :adb pull /sdcard/sc.png
operation
Let's try the click operation first
Using detectors Get coordinates 
Click punctuation 1 The location of Select the coordinates
Put the mouse over the punctuation 2 The location of Punctuation in the upper left corner 3 The corresponding coordinates will appear write down stay cmd The administrator ordered
Input adb shell input tap 345 1078
remember We are cmd Any command you type is an administrator command 
You can see that it has been clicked
Next try Text input In the Administrator cmd Under orders
Input adb shell input text 123456

It has been successful
Next You can use the detector Click on any element with coordinates
We can create a new text
Write you adb The order of Conduct automated tests
The blogger has written a
mumu The browser has a vertical screen
adb shell input tap 345 1077
adb shell input tap 88 721
adb shell input tap 50 251
timeout/T 3
adb shell input text 123456
adb shell input text 123456
adb shell input tap 652 75
timeout/T 3
Write the above contents into the text file The suffix of the document is changed to bat
timeout/T 3 It means waiting Wait three seconds
Start Youdao cloud first Then the administrator runs this bat file
If you can't click Then change coordinate The simulator screen resolution is different The coordinates will change 
You can see that it has been written in
Okay
Here our environment construction is over
Isn't that easy
You can raise more questions when you encounter After all, the blogger made a mistake More than just a lot of emm Can help you solve
边栏推荐
- [dish of learning notes dog learning C] detailed operator
- MySQL - unique index
- NiO knowledge points
- 《nlp入门+实战:第二章:pytorch的入门使用 》
- Mysql InnoDB下联合索引的索引数量?
- Machine learning quiz (10) using QT and tensorflow to create cnn/fnn test environment
- PC Museum (2) 1972 hp-9830a
- MySQL performance optimization (IV): how to use indexes efficiently and correctly
- Record AP and map calculation examples
- 第五章 修改实现(IMPL)类
猜你喜欢

《nlp入门+实战:第二章:pytorch的入门使用 》

二叉树基础知识概览

Web Security Foundation - file upload (file upload bypass)

Image processing: rgb565 to rgb888

Ffmpeg splash screen solution (modify the source code and discard incomplete frames)

Create a vertical seekbar from scratch

Intranet remote control tool under Windows

NiO knowledge points

Will not be rejected! Learn the distributed architecture notes sorted out by Alibaba Daniel in 35 days, with a salary increase of 20K

Distributed transaction processing scheme big PK!
随机推荐
Machine learning quiz (10) using QT and tensorflow to create cnn/fnn test environment
MySQL——锁
5个最佳WordPress广告插件
Erlang学习02
Sentinel 三种流控效果
Constant pointer, pointer constant
N-tree, page_ Size, database strict mode modification, and the difference between delete and drop in the database
Simply use golang SQLC to generate MySQL query code
Sentinel 流量控制快速入门
[dish of learning notes dog learning C] detailed operator
Domain Driven practice summary (basic theory summary and analysis + Architecture Analysis and code design + specific application design analysis V) [easy to understand]
MySQL - 全文索引
CMS vulnerability recurrence - foreground arbitrary user password modification vulnerability
Android uses JDBC to connect to a remote database
Try the video for 5 minutes [easy to understand]
[dish of learning notes dog learning C] advanced pointer
火山引擎:开放字节跳动同款AI基建,一套系统解决多重训练任务
很佩服的一个Google大佬,离职了。。
Differential restraint system -- 1 and 2 -- May 27, 2022
Sentinel implements the persistence of pull pattern rules
