[android]android自動化測試二之命令列建立AVD
判斷AVD是否已經開啟:
adb -s emulator-57409 shell getprop dev.bootcomplete
如果結果返回1代表AVD成功啟動了
命令列開啟方式:
1、首先你要開啟android模擬器 (下面命令列開啟的4步驟我是引用百度上的)
1).找到SDK的tools資料夾,我的在D:\android-sdk-windows\tools;
2).如果沒有建立AVD的話,可以用命令android list targets檢視各版本對應的id;
然後android create avd --target 5 --name Android2.2;//我這裡5對應的是android2.2
3).用命令android list avd檢視自己以建立的AVD
4).emulator -debug avd_config -avd Android2.2就可以開啟AVD了,就是有點慢
或者在eclipse上直接開啟一個android程式。
2、然後輸入 adb install xxx.apk,在模擬器上點選對應應用即可(安裝apk後的應用程式名不知道的話得仔細找哦,肯定在模擬器上的)。
注:xxx.apk包含路徑名,在命令列你只要直接把apk檔案拖至windows命令視窗就可以載入完整路徑了。
自動解鎖螢幕,自動虛擬機器啟動或休眠,使用命令呼叫logcat,刪除虛擬機器
1. The command line to launch the test AVD we just created would be:
$ emulator -avd test -no-window -no-audio -no-boot-anim -port 5580 &
2. The port must be an integer between 5554 and 5584:
$ adb devices
List of devices attached
emulator-5580
device
This shows the device in the device list.
3. The next step is to install the application and the tests:
$ adb -s emulator-5580 install\
TemperatureConverter/bin/TemperatureConverter.apk
347 KB/s (16632 bytes in 0.046s)
pkg: /data/local/tmp/TemperatureConverter.apk
Success
$ adb -s emulator-5580 install\
TemperatureConverterTest/bin/TemperatureConverterTest.apk
222 KB/s (16632 bytes in 0.072s)
pkg: /data/local/tmp/TemperatureConverterTest.apk
Success
4. Then we can use the specified serial number to run the tests on it:
$ adb -s emulator-5580 shell am instrument -w\
com.example.aatg.tc.test/android.test.InstrumentationTestRunner
com.example.aatg.tc.test.EditNumberTests:......
com.example.aatg.tc.test.
TemperatureConverterActivityTests:..........
com.example.aatg.tc.test.TemperatureConverterTests:....
Test results for InstrumentationTestRunner=....................
Time: 25.295
OK (20 tests)
To unlock the screen you can use:
$ adb -s emulator-5580 emu event send EV_KEY:KEY_MENU:1 EV_KEY:KEY_MENU:0
解鎖螢幕
向裝置傳送螢幕解鎖命令:
adb shell input keyevent 82
To do this, the following permission should be added to the manifest file
(AndroidManifest.xml), and then disable the screen lock in your application
under test.
To add the permission, add this element to the manifest:
<manifest>
...
<uses-permission android:name="android.permission.DISABLE_KEYGUARD"/>
...
</manifest>
Then in the Activity under test you should add the following code, preferably in
onResume():
mKeyGuardManager =
(KeyguardManager) getSystemService(KEYGUARD_SERVICE);
mLock = mKeyGuardManager.newKeyguardLock("com.example.aatg.tc");
mLock.disableKeyguard();
That is, get the KeyguardManager, then obtain the KeyguardLock specifying a tag,
customize the package name to be able to debug who is disabling the keyguard.
Then disable the keyguard from showing using disableKeyguard(). If the
keyguard is currently showing, it is hidden. The keyguard will be prevented from
showing again until reenableKeyguard() is called.
$ adb -s emulator-5580 shell 'stop; sleep 5; start'
This command line opens the emulator shell for our emulator and runs the stop and
start commands.
The evolution of these commands can be monitored using the logcat command:
$ adb -s emulator-5580 logcat
$ adb -s emulator-5580 emu kill
This will stop the emulator and free the used resources and terminate the emulator
process on the host computer.
adb -s emulator-57409 shell getprop dev.bootcomplete
如果結果返回1代表AVD成功啟動了
命令列開啟方式:
1、首先你要開啟android模擬器 (下面命令列開啟的4步驟我是引用百度上的)
1).找到SDK的tools資料夾,我的在D:\android-sdk-windows\tools;
2).如果沒有建立AVD的話,可以用命令android list targets檢視各版本對應的id;
然後android create avd --target 5 --name Android2.2;//我這裡5對應的是android2.2
3).用命令android list avd檢視自己以建立的AVD
4).emulator -debug avd_config -avd Android2.2就可以開啟AVD了,就是有點慢
或者在eclipse上直接開啟一個android程式。
2、然後輸入 adb install xxx.apk,在模擬器上點選對應應用即可(安裝apk後的應用程式名不知道的話得仔細找哦,肯定在模擬器上的)。
注:xxx.apk包含路徑名,在命令列你只要直接把apk檔案拖至windows命令視窗就可以載入完整路徑了。
自動解鎖螢幕,自動虛擬機器啟動或休眠,使用命令呼叫logcat,刪除虛擬機器
1. The command line to launch the test AVD we just created would be:
$ emulator -avd test -no-window -no-audio -no-boot-anim -port 5580 &
2. The port must be an integer between 5554 and 5584:
$ adb devices
List of devices attached
emulator-5580
device
This shows the device in the device list.
3. The next step is to install the application and the tests:
$ adb -s emulator-5580 install\
TemperatureConverter/bin/TemperatureConverter.apk
347 KB/s (16632 bytes in 0.046s)
pkg: /data/local/tmp/TemperatureConverter.apk
Success
$ adb -s emulator-5580 install\
TemperatureConverterTest/bin/TemperatureConverterTest.apk
222 KB/s (16632 bytes in 0.072s)
pkg: /data/local/tmp/TemperatureConverterTest.apk
Success
4. Then we can use the specified serial number to run the tests on it:
$ adb -s emulator-5580 shell am instrument -w\
com.example.aatg.tc.test/android.test.InstrumentationTestRunner
com.example.aatg.tc.test.EditNumberTests:......
com.example.aatg.tc.test.
TemperatureConverterActivityTests:..........
com.example.aatg.tc.test.TemperatureConverterTests:....
Test results for InstrumentationTestRunner=....................
Time: 25.295
OK (20 tests)
To unlock the screen you can use:
$ adb -s emulator-5580 emu event send EV_KEY:KEY_MENU:1 EV_KEY:KEY_MENU:0
解鎖螢幕
向裝置傳送螢幕解鎖命令:
adb shell input keyevent 82
To do this, the following permission should be added to the manifest file
(AndroidManifest.xml), and then disable the screen lock in your application
under test.
To add the permission, add this element to the manifest:
<manifest>
...
<uses-permission android:name="android.permission.DISABLE_KEYGUARD"/>
...
</manifest>
Then in the Activity under test you should add the following code, preferably in
onResume():
mKeyGuardManager =
(KeyguardManager) getSystemService(KEYGUARD_SERVICE);
mLock = mKeyGuardManager.newKeyguardLock("com.example.aatg.tc");
mLock.disableKeyguard();
That is, get the KeyguardManager, then obtain the KeyguardLock specifying a tag,
customize the package name to be able to debug who is disabling the keyguard.
Then disable the keyguard from showing using disableKeyguard(). If the
keyguard is currently showing, it is hidden. The keyguard will be prevented from
showing again until reenableKeyguard() is called.
$ adb -s emulator-5580 shell 'stop; sleep 5; start'
This command line opens the emulator shell for our emulator and runs the stop and
start commands.
The evolution of these commands can be monitored using the logcat command:
$ adb -s emulator-5580 logcat
$ adb -s emulator-5580 emu kill
This will stop the emulator and free the used resources and terminate the emulator
process on the host computer.
相關文章
- Android 自動化測試之 MonkeyAndroid
- Android 談談自動化測試Android
- Android自動化測試第二篇 Appnium環境搭建AndroidAPP
- android 5個自動化測試Ui框架AndroidUI框架
- Android自動化測試入門(四)單元測試Android
- Appium自動化測試之常用的adb命令APP
- Android UXSS階段性小結及自動化測試AndroidUX
- 使用命令列建立Android Studio專案命令列Android
- 自動化測試總結(二)
- 二、介面自動化測試(2)
- Android熱補丁之Robust(二)自動化補丁原理解析Android
- 深圳軟體測試培訓學習:Android常用自動化測試工具【千鋒】Android
- 解放雙手 - Android 開發應該嘗試的 UI 自動化測試AndroidUI
- 測試開發之自動化篇-自動化測試框架設計框架
- UI自動化測試之AirtestUIAI
- Android 自動化測試及效能資料採集的 Python 指令碼AndroidPython指令碼
- 工作專案經驗總結(1)-- 投影儀自動化測試 (Android)Android
- 自動化測試系列 —— UI自動化測試UI
- 面試Tip:Android優化之APP啟動優化面試Android優化APP
- Android UI 測試指南之 EspressoAndroidUIEspresso
- AutoRunner 功能自動化測試專案實訓之自動化測試原理(一)
- 3分鐘瞭解Appium:使用appium做Android手機自動化測試!APPAndroid
- Android + Appium 自動化測試完整的環境配置及程式碼詳解AndroidAPP
- Android常用9種自動化測試框架對比,Appium有哪些優勢?Android框架APP
- 測試 之Java單元測試、Android單元測試JavaAndroid
- android測試常用的adb命令以及進行Monkey測試Android
- 記錄Android學習-遇到的第一個問題,AS自帶AVD無法啟動Android
- 深圳軟體測試學習:如何在Android手機上進行自動化測試【千鋒】Android
- Android AVD | (A small tip)重新建立一個新的(刪除舊的)AVD模擬器,解決了大部分無語的AVD問題...Android
- 【自動化測試入門】自動化測試思維
- 移動APP測試:Android螢幕適配問題二APPAndroid
- 從探索到突破:網易雲音樂Android自動化效能測試實踐Android
- 全副武裝!Android UI 自動化測試在 RxImagePicker 中的實踐歷程AndroidUI
- Android自動化 - 基礎總集Android
- 前端自動化測試之葵花寶典前端
- CukeTest+Puppeteer的Web自動化測試(二)Web
- 自動化裝置測試與自動化測試的區別
- 如何做自動化測試?什麼是自動化測試?
- Android自動化頁面測速在美團的實踐Android