1 安装node.js
1.1 安装node.js
http://nodejs.cn/download/
1.2、下载后直接点击exe,按照提示一步一步的安装
1.3 安装成功后,运行cmd,输入node –v,如果安装成功,会输出如下版本信息
2 eclipse android开发环境搭建
2.1 用eclipse开发,需要下载jdk、eclipse、adt(android development tools 安卓开发工具包)、sdk(software development kit 软件开发工具包),如果不用真机而用模拟器则还需要下载avd(android virtual device 安卓虚拟设备)。为了方便我直接下载的是adt-bundle-windows。
目录如下:
2.2 设置环境变量
ANDROID_HOME = D:\software\sdk ANDROID_SDK_HOME = D:\software\sdk PATH = %ANDROID_HOME%\tools;%ANDROID_HOME%\platform-tools;
在eclipse选择sdk,windows->preferences
2.3 查看连接设备。手机启动开发者模式,用USB连接电脑,运行cmd,到sdk的platform-tools,输入adb devices,如果看到设备号即成功。
3 安装appium
3.1、下载文件
https://bitbucket.org/appium/appium.app/downloads/
3.2 安装,点击exe,一步一步按照提示操作,直至完成。过程中会提示让你安装.net framework,可以安装完appium再安装它,这一点还是蛮好的,软件百度一下就有了。
3.3 设置环境变量,在path添加:
3.4 运行cmd,输入appium-doctor,出现"All Checks were successful"即安装成功。
4 联机测试
4.1 手机连接电脑。手机启动开发者模式,用USB连接电脑,运行cmd,到sdk的platform-tools,输入adb devices。
4.2 启动appium。
双击appium快捷键。
点击launch
4.3 启动应用。启动应用有两种方式
一 通过appium。
1)从应用市场下载"快钱钱包"到本地,双击appium快捷键,点击小安卓机器人android settings选择应用。
tips:手机型号查看。比如华为手机,设置->关于手机->型号。其他手机类似。
2)general settings
3)点击launch
手机应用会自动打开
appium日志:
> Launching Appium server with command: D:\software\Appium_windows\Appium\node.exe lib\server\main.js --address 127.0.0.1 --port 4723 --app D:\software\adt-bundle-windows\sdk\platform-tools\app_installed\kuaiqianqianbaoapp.apk --app-activity com.bill99.kuaiqian.ui.base.WelcomeActivity --app-pkg com.bill99.kuaiqian --pre-launch --session-override --platform-name Android --platform-version 23 --automation-name Appium --device-name "HUAWEI GRA-UL00" --log-no-color
> info: [debug] Starting Appium in pre-launch mode
> info: Pre-launching app
> info: [debug] Using local app from command line: D:\software\adt-bundle-windows\sdk\platform-tools\app_installed\kuaiqianqianbaoapp.apk
> info: [debug] Creating new appium session cea2d326-6a15-43e9-9482-36cf2e89a73a
> info: Starting android appium
> info: [debug] Getting Java version
> info: Java version is: 1.7.0_72
> info: [debug] Checking whether adb is present
> info: [debug] Using adb from D:\software\sdk\platform-tools\adb.exe
> info: [debug] Using fast reset? true
> info: [debug] Preparing device for session
> info: [debug] Checking whether app is actually present
> info: Retrieving device
> info: [debug] Trying to find a connected android device
> info: [debug] Getting connected devices...
> info: [debug] executing cmd: D:\software\sdk\platform-tools\adb.exe devices
> info: [debug] 1 device(s) connected
> info: Found device T7G5T15427004998
> info: [debug] Setting device id to T7G5T15427004998
> info: [debug] Waiting for device to be ready and to respond to shell commands (timeout = 5)
> info: [debug] executing cmd: D:\software\sdk\platform-tools\adb.exe -s T7G5T15427004998 wait-for-device
> info: [debug] executing cmd: D:\software\sdk\platform-tools\adb.exe -s T7G5T15427004998 shell "echo 'ready'"
> info: [debug] Starting logcat capture
> info: [debug] Getting device API level
> info: [debug] executing cmd: D:\software\sdk\platform-tools\adb.exe -s T7G5T15427004998 shell "getprop ro.build.version.sdk"
> info: [debug] Device is at API Level 21
> info: Device API level is: 21
> info: [debug] Extracting strings for language: default
> info: [debug] executing cmd: D:\software\sdk\platform-tools\adb.exe -s T7G5T15427004998 shell "getprop persist.sys.language"
> info: [debug] Current device persist.sys.language: zh
> info: [debug] java -jar "D:\software\Appium_windows\Appium\node_modules\appium\node_modules\appium-adb\jars\appium_apk_tools.jar" "stringsFromApk" "D:\software\adt-bundle-windows\sdk\platform-tools\app_installed\kuaiqianqianbaoapp.apk" "C:\Users\xiangnan.qi\AppData\Local\Temp\com.bill99.kuaiqian" zh
> info: [debug] Reading strings from converted strings.json
> info: [debug] Setting language to default
> info: [debug] executing cmd: D:\software\sdk\platform-tools\adb.exe -s T7G5T15427004998 push "C:\\Users\\xiangnan.qi\\AppData\\Local\\Temp\\com.bill99.kuaiqian\\strings.json" /data/local/tmp
> info: [debug] Checking whether aapt is present
> info: [debug] Using aapt from D:\software\sdk\build-tools\android-4.3\aapt.exe
> info: [debug] Retrieving process from manifest.
> info: [debug] executing cmd: D:\software\sdk\build-tools\android-4.3\aapt.exe dump xmltree D:\software\adt-bundle-windows\sdk\platform-tools\app_installed\kuaiqianqianbaoapp.apk AndroidManifest.xml
> info: [debug] Set app process to: com.bill99.kuaiqian
> info: [debug] Not uninstalling app since server not started with --full-reset
> info: [debug] Checking app cert for D:\software\adt-bundle-windows\sdk\platform-tools\app_installed\kuaiqianqianbaoapp.apk.
> info: [debug] executing cmd: java -jar D:\software\Appium_windows\Appium\node_modules\appium\node_modules\appium-adb\jars\verify.jar D:\software\adt-bundle-windows\sdk\platform-tools\app_installed\kuaiqianqianbaoapp.apk
> info: [debug] App already signed.
> info: [debug] Zip-aligning D:\software\adt-bundle-windows\sdk\platform-tools\app_installed\kuaiqianqianbaoapp.apk
> info: [debug] Checking whether zipalign is present
> info: [debug] Using zipalign from D:\software\sdk\tools\zipalign.exe
> info: [debug] Zip-aligning apk.
> info: [debug] executing cmd: D:\software\sdk\tools\zipalign.exe -f 4 D:\software\adt-bundle-windows\sdk\platform-tools\app_installed\kuaiqianqianbaoapp.apk C:\Users\xiangnan.qi\AppData\Local\Temp\11703-7352-r0a80d\appium.tmp
> info: [debug] MD5 for app is 072b08f27c14683756eafc3418ed3971
> info: [debug] executing cmd: D:\software\sdk\platform-tools\adb.exe -s T7G5T15427004998 shell "ls /data/local/tmp/072b08f27c14683756eafc3418ed3971.apk"
> info: [debug] Getting install status for com.bill99.kuaiqian
> info: [debug] Getting device API level
> info: [debug] executing cmd: D:\software\sdk\platform-tools\adb.exe -s T7G5T15427004998 shell "getprop ro.build.version.sdk"
> info: [debug] Device is at API Level 21
> info: [debug] executing cmd: D:\software\sdk\platform-tools\adb.exe -s T7G5T15427004998 shell "pm list packages -3 com.bill99.kuaiqian"
> info: [debug] App is installed
> info: App is already installed, resetting app
> info: [debug] Running fast reset (stop and clear)
> info: [debug] executing cmd: D:\software\sdk\platform-tools\adb.exe -s T7G5T15427004998 shell "am force-stop com.bill99.kuaiqian"
> info: [debug] executing cmd: D:\software\sdk\platform-tools\adb.exe -s T7G5T15427004998 shell "pm clear com.bill99.kuaiqian"
> info: [debug] Forwarding system:4724 to device:4724
> info: [debug] executing cmd: D:\software\sdk\platform-tools\adb.exe -s T7G5T15427004998 forward tcp:4724 tcp:4724
> info: [debug] Pushing appium bootstrap to device...
> info: [debug] executing cmd: D:\software\sdk\platform-tools\adb.exe -s T7G5T15427004998 push "D:\\software\\Appium_windows\\Appium\\node_modules\\appium\\build\\android_bootstrap\\AppiumBootstrap.jar" /data/local/tmp/
> info: [debug] Pushing settings apk to device...
> info: [debug] executing cmd: D:\software\sdk\platform-tools\adb.exe -s T7G5T15427004998 install "D:\software\Appium_windows\Appium\node_modules\appium\build\settings_apk\settings_apk-debug.apk"
> info: [debug] Pushing unlock helper app to device...
> info: [debug] executing cmd: D:\software\sdk\platform-tools\adb.exe -s T7G5T15427004998 install "D:\software\Appium_windows\Appium\node_modules\appium\build\unlock_apk\unlock_apk-debug.apk"
> info: Starting App
> info: [debug] Attempting to kill all 'uiautomator' processes
> info: [debug] Getting all processes with 'uiautomator'
> info: [debug] executing cmd: D:\software\sdk\platform-tools\adb.exe -s T7G5T15427004998 shell "ps 'uiautomator'"
> info: [debug] No matching processes found
> info: [debug] Running bootstrap
> info: [debug] spawning: D:\software\sdk\platform-tools\adb.exe -s T7G5T15427004998 shell uiautomator runtest AppiumBootstrap.jar -c io.appium.android.bootstrap.Bootstrap -e pkg com.bill99.kuaiqian -e disableAndroidWatchers false
> info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: numtests=1
> info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: stream=
> info: [debug] [UIAUTOMATOR STDOUT] io.appium.android.bootstrap.Bootstrap:
> info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: id=UiAutomatorTestRunner
> info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: test=testRunServer
> info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: class=io.appium.android.bootstrap.Bootstrap
> info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: current=1
> info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS_CODE: 1
> info: [debug] [BOOTSTRAP] [debug] Socket opened on port 4724
> info: [debug] [BOOTSTRAP] [debug] Appium Socket Server Ready
> info: [debug] [BOOTSTRAP] [debug] Loading json...
> info: [debug] [BOOTSTRAP] [debug] json loading complete.
> info: [debug] [BOOTSTRAP] [debug] Registered crash watchers.
> info: [debug] Waking up device if it's not alive
> info: [debug] Pushing command to appium work queue: ["wake",{}]
> info: [debug] [BOOTSTRAP] [debug] Client connected
> info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"wake","params":{}}
> info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
> info: [debug] [BOOTSTRAP] [debug] Got command action: wake
> info: [debug] [BOOTSTRAP] [debug] Returning result: {"status":0,"value":true}
> info: [debug] executing cmd: D:\software\sdk\platform-tools\adb.exe -s T7G5T15427004998 shell "dumpsys window"
> info: [debug] Screen already unlocked, continuing.
> info: [debug] Pushing command to appium work queue: ["getDataDir",{}]
> info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"getDataDir","params":{}}
> info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
> info: [debug] [BOOTSTRAP] [debug] Got command action: getDataDir
> info: [debug] [BOOTSTRAP] [debug] Returning result: {"status":0,"value":"\/data\/local\/tmp"}
> info: [debug] dataDir set to: /data/local/tmp
> info: [debug] Pushing command to appium work queue: ["compressedLayoutHierarchy",{"compressLayout":false}]
> info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"compressedLayoutHierarchy","params":{"compressLayout":false}}
> info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
> info: [debug] [BOOTSTRAP] [debug] Got command action: compressedLayoutHierarchy
> info: [debug] [BOOTSTRAP] [debug] Returning result: {"status":0,"value":false}
> info: [debug] Getting device API level
> info: [debug] executing cmd: D:\software\sdk\platform-tools\adb.exe -s T7G5T15427004998 shell "getprop ro.build.version.sdk"
> info: [debug] Device is at API Level 21
> info: [debug] executing cmd: D:\software\sdk\platform-tools\adb.exe -s T7G5T15427004998 shell "am start -S -a android.intent.action.MAIN -c android.intent.category.LAUNCHER -f 0x10200000 -n com.bill99.kuaiqian/com.bill99.kuaiqian.ui.base.WelcomeActivity"
> info: [debug] Waiting for pkg "com.bill99.kuaiqian" and activity "com.bill99.kuaiqian.ui.base.WelcomeActivity" to be focused
> info: [debug] Getting focused package and activity
> info: [debug] executing cmd: D:\software\sdk\platform-tools\adb.exe -s T7G5T15427004998 shell "dumpsys window windows"
> info: [debug] executing cmd: D:\software\sdk\platform-tools\adb.exe -s T7G5T15427004998 shell "getprop ro.build.version.release"
> info: [debug] Device is at release version 5.0.1
> info: [debug] Device launched! Ready for commands
> info: [debug] Setting command timeout to the default of 60 secs
> info: Welcome to Appium v1.4.16 (REV ae6877eff263066b26328d457bd285c0cc62430d)
> info: Appium REST http interface listener started on 127.0.0.1:4723
> info: [debug] Non-default server args: {"app":"D:\\software\\adt-bundle-windows\\sdk\\platform-tools\\app_installed\\kuaiqianqianbaoapp.apk","address":"127.0.0.1","sessionOverride":true,"launch":true,"logNoColors":true,"androidPackage":"com.bill99.kuaiqian","androidActivity":"com.bill99.kuaiqian.ui.base.WelcomeActivity","deviceName":"HUAWEI GRA-UL00","platformName":"Android","platformVersion":"23","automationName":"Appium"}
> info: Console LogLevel: debug
应用默认打开60秒自动退出
注意:
应用如果打不开则需要检查电脑的安装包是否损坏。将app安装到手机上看看能否打开。
二 通过脚本。
1)打开appium。点击luanch
注意:
之前的android settings和general settings的选项都关闭掉。
2)在eclipse新建junit(实现打开应用,从应用首页到理财界面),然后运行。
参考代码只需要更改:app/deviceName/appPackage/appActivity。分别是app路径/设备名称/应用package/应用activity
package com.glen.demo;import io.appium.java_client.AppiumDriver;import java.io.File; import java.net.URL;import org.junit.After; import org.junit.Before; import org.junit.Test; import org.openqa.selenium.WebElement; import org.openqa.selenium.remote.DesiredCapabilities;public class KQQBTest {private AppiumDriver driver;@Beforepublic void setUp() throws Exception {File app = new File("D:\\software\\adt-bundle-windows\\sdk\\platform-tools\\app_installed","kuaiqianqianbaoapp.apk");// 设置自动化相关参数DesiredCapabilities capabilities = new DesiredCapabilities();capabilities.setCapability("platformName", "Android");
capabilities.setCapability("deviceName", "HUAWEI GRA-UL00");// 设置apk路径capabilities.setCapability("app", app.getAbsolutePath());capabilities.setCapability("noSign", true);// 设置app的主包名和主类名capabilities.setCapability("appPackage","com.bill99.kuaiqian");capabilities.setCapability("appActivity", "com.bill99.kuaiqian.ui.base.WelcomeActivity");// 初始化driver = new AppiumDriver(new URL("http://127.0.0.1:4723/wd/hub"),capabilities);Thread.sleep(15*1000);}@Testpublic void test() {WebElement licai = driver.findElementById("com.bill99.kuaiqian:id/q9");System.out.println("控件文本"+licai.getText());licai.click();}@Afterpublic void tearDown() throws Exception {driver.quit();} }
控制台日志:
手机理财截图:
appium日志:
> info: --> POST /wd/hub/session {"desiredCapabilities":{"app":"D:\\software\\adt-bundle-windows\\sdk\\platform-tools\\app_installed\\kuaiqianqianbaoapp.apk","deviceName":"HUAWEI GRA-UL00","platformName":"Android","appActivity":"com.bill99.kuaiqian.ui.base.WelcomeActivity","noSign":true,"appPackage":"com.bill99.kuaiqian"}} > info: Client User-Agent string: Apache-HttpClient/4.3.4 (java 1.5) > info: [debug] Using local app from desired caps: D:\software\adt-bundle-windows\sdk\platform-tools\app_installed\kuaiqianqianbaoapp.apk > info: [debug] Creating new appium session 80a6ad1b-ed9d-4b75-be4e-31996205002f > info: Starting android appium > info: [debug] Getting Java version > info: Java version is: 1.7.0_72 > info: [debug] Checking whether adb is present > info: [debug] Using adb from D:\software\sdk\platform-tools\adb.exe > info: [debug] Using fast reset? true > info: [debug] Preparing device for session > info: [debug] Checking whether app is actually present > info: Retrieving device > info: [debug] Trying to find a connected android device > info: [debug] Getting connected devices... > info: [debug] executing cmd: D:\software\sdk\platform-tools\adb.exe devices > info: [debug] 1 device(s) connected > info: Found device T7G5T15427004998 > info: [debug] Setting device id to T7G5T15427004998 > info: [debug] Waiting for device to be ready and to respond to shell commands (timeout = 5) > info: [debug] executing cmd: D:\software\sdk\platform-tools\adb.exe -s T7G5T15427004998 wait-for-device > info: [debug] executing cmd: D:\software\sdk\platform-tools\adb.exe -s T7G5T15427004998 shell "echo 'ready'" > info: [debug] Starting logcat capture > info: [debug] Getting device API level > info: [debug] executing cmd: D:\software\sdk\platform-tools\adb.exe -s T7G5T15427004998 shell "getprop ro.build.version.sdk" > info: [debug] Device is at API Level 21 > info: Device API level is: 21 > info: [debug] Extracting strings for language: default > info: [debug] executing cmd: D:\software\sdk\platform-tools\adb.exe -s T7G5T15427004998 shell "getprop persist.sys.language" > info: [debug] Current device persist.sys.language: zh > info: [debug] java -jar "D:\software\Appium_windows\Appium\node_modules\appium\node_modules\appium-adb\jars\appium_apk_tools.jar" "stringsFromApk" "D:\software\adt-bundle-windows\sdk\platform-tools\app_installed\kuaiqianqianbaoapp.apk" "C:\Users\xiangnan.qi\AppData\Local\Temp\com.bill99.kuaiqian" zh > info: [debug] Reading strings from converted strings.json > info: [debug] Setting language to default > info: [debug] executing cmd: D:\software\sdk\platform-tools\adb.exe -s T7G5T15427004998 push "C:\\Users\\xiangnan.qi\\AppData\\Local\\Temp\\com.bill99.kuaiqian\\strings.json" /data/local/tmp > info: [debug] Checking whether aapt is present > info: [debug] Using aapt from D:\software\sdk\build-tools\android-4.3\aapt.exe > info: [debug] Retrieving process from manifest. > info: [debug] executing cmd: D:\software\sdk\build-tools\android-4.3\aapt.exe dump xmltree D:\software\adt-bundle-windows\sdk\platform-tools\app_installed\kuaiqianqianbaoapp.apk AndroidManifest.xml > info: [debug] Set app process to: com.bill99.kuaiqian > info: [debug] Not uninstalling app since server not started with --full-reset > info: [debug] noSign capability set to true, skipping checking and signing of app > info: [debug] MD5 for app is 072b08f27c14683756eafc3418ed3971 > info: [debug] executing cmd: D:\software\sdk\platform-tools\adb.exe -s T7G5T15427004998 shell "ls /data/local/tmp/072b08f27c14683756eafc3418ed3971.apk" > info: [debug] Getting install status for com.bill99.kuaiqian > info: [debug] Getting device API level > info: [debug] executing cmd: D:\software\sdk\platform-tools\adb.exe -s T7G5T15427004998 shell "getprop ro.build.version.sdk" > info: [debug] Device is at API Level 21 > info: [debug] executing cmd: D:\software\sdk\platform-tools\adb.exe -s T7G5T15427004998 shell "pm list packages -3 com.bill99.kuaiqian" > info: [debug] App is installed > info: App is already installed, resetting app > info: [debug] Running fast reset (stop and clear) > info: [debug] executing cmd: D:\software\sdk\platform-tools\adb.exe -s T7G5T15427004998 shell "am force-stop com.bill99.kuaiqian" > info: [debug] executing cmd: D:\software\sdk\platform-tools\adb.exe -s T7G5T15427004998 shell "pm clear com.bill99.kuaiqian" > info: [debug] Forwarding system:4724 to device:4724 > info: [debug] executing cmd: D:\software\sdk\platform-tools\adb.exe -s T7G5T15427004998 forward tcp:4724 tcp:4724 > info: [debug] Pushing appium bootstrap to device... > info: [debug] executing cmd: D:\software\sdk\platform-tools\adb.exe -s T7G5T15427004998 push "D:\\software\\Appium_windows\\Appium\\node_modules\\appium\\build\\android_bootstrap\\AppiumBootstrap.jar" /data/local/tmp/ > info: [debug] Pushing settings apk to device... > info: [debug] executing cmd: D:\software\sdk\platform-tools\adb.exe -s T7G5T15427004998 install "D:\software\Appium_windows\Appium\node_modules\appium\build\settings_apk\settings_apk-debug.apk" > info: [debug] Pushing unlock helper app to device... > info: [debug] executing cmd: D:\software\sdk\platform-tools\adb.exe -s T7G5T15427004998 install "D:\software\Appium_windows\Appium\node_modules\appium\build\unlock_apk\unlock_apk-debug.apk" > info: Starting App > info: [debug] Attempting to kill all 'uiautomator' processes > info: [debug] Getting all processes with 'uiautomator' > info: [debug] executing cmd: D:\software\sdk\platform-tools\adb.exe -s T7G5T15427004998 shell "ps 'uiautomator'" > info: [debug] No matching processes found > info: [debug] Running bootstrap > info: [debug] spawning: D:\software\sdk\platform-tools\adb.exe -s T7G5T15427004998 shell uiautomator runtest AppiumBootstrap.jar -c io.appium.android.bootstrap.Bootstrap -e pkg com.bill99.kuaiqian -e disableAndroidWatchers false > info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: numtests=1 > info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: stream= > info: [debug] [UIAUTOMATOR STDOUT] io.appium.android.bootstrap.Bootstrap: > info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: id=UiAutomatorTestRunner > info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: test=testRunServer > info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: class=io.appium.android.bootstrap.Bootstrap > info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: current=1 > info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS_CODE: 1 > info: [debug] [BOOTSTRAP] [debug] Socket opened on port 4724 > info: [debug] [BOOTSTRAP] [debug] Appium Socket Server Ready > info: [debug] [BOOTSTRAP] [debug] Loading json... > info: [debug] [BOOTSTRAP] [debug] json loading complete. > info: [debug] Waking up device if it's not alive > info: [debug] Pushing command to appium work queue: ["wake",{}] > info: [debug] [BOOTSTRAP] [debug] Registered crash watchers. > info: [debug] [BOOTSTRAP] [debug] Client connected > info: [debug] executing cmd: D:\software\sdk\platform-tools\adb.exe -s T7G5T15427004998 shell "dumpsys window" > info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"wake","params":{}} > info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION > info: [debug] [BOOTSTRAP] [debug] Got command action: wake > info: [debug] [BOOTSTRAP] [debug] Returning result: {"status":0,"value":true} > info: [debug] Screen already unlocked, continuing. > info: [debug] Pushing command to appium work queue: ["getDataDir",{}] > info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"getDataDir","params":{}} > info: [debug] dataDir set to: /data/local/tmp > info: [debug] Pushing command to appium work queue: ["compressedLayoutHierarchy",{"compressLayout":false}] > info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION > info: [debug] [BOOTSTRAP] [debug] Got command action: getDataDir > info: [debug] [BOOTSTRAP] [debug] Returning result: {"status":0,"value":"\/data\/local\/tmp"} > info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"compressedLayoutHierarchy","params":{"compressLayout":false}} > info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION > info: [debug] [BOOTSTRAP] [debug] Got command action: compressedLayoutHierarchy > info: [debug] Getting device API level > info: [debug] executing cmd: D:\software\sdk\platform-tools\adb.exe -s T7G5T15427004998 shell "getprop ro.build.version.sdk" > info: [debug] [BOOTSTRAP] [debug] Returning result: {"status":0,"value":false} > info: [debug] Device is at API Level 21 > info: [debug] executing cmd: D:\software\sdk\platform-tools\adb.exe -s T7G5T15427004998 shell "am start -S -a android.intent.action.MAIN -c android.intent.category.LAUNCHER -f 0x10200000 -n com.bill99.kuaiqian/com.bill99.kuaiqian.ui.base.WelcomeActivity" > info: [debug] Waiting for pkg "com.bill99.kuaiqian" and activity "com.bill99.kuaiqian.ui.base.WelcomeActivity" to be focused > info: [debug] Getting focused package and activity > info: [debug] executing cmd: D:\software\sdk\platform-tools\adb.exe -s T7G5T15427004998 shell "dumpsys window windows" > info: [debug] executing cmd: D:\software\sdk\platform-tools\adb.exe -s T7G5T15427004998 shell "getprop ro.build.version.release" > info: [debug] Device is at release version 5.0.1 > info: [debug] Device launched! Ready for commands > info: [debug] Setting command timeout to the default of 60 secs > info: [debug] Appium session started with sessionId 80a6ad1b-ed9d-4b75-be4e-31996205002f > info: <-- POST /wd/hub/session 303 15604.592 ms - 74 > info: --> GET /wd/hub/session/80a6ad1b-ed9d-4b75-be4e-31996205002f {} > info: [debug] Responding to client with success: {"status":0,"value":{"platform":"LINUX","browserName":"Android","platformVersion":"5.0.1","webStorageEnabled":false,"takesScreenshot":true,"javascriptEnabled":true,"databaseEnabled":false,"networkConnectionEnabled":true,"locationContextEnabled":false,"warnings":{},"desired":{"app":"D:\\software\\adt-bundle-windows\\sdk\\platform-tools\\app_installed\\kuaiqianqianbaoapp.apk","deviceName":"HUAWEI GRA-UL00","platformName":"Android","appActivity":"com.bill99.kuaiqian.ui.base.WelcomeActivity","noSign":true,"appPackage":"com.bill99.kuaiqian"},"app":"D:\\software\\adt-bundle-windows\\sdk\\platform-tools\\app_installed\\kuaiqianqianbaoapp.apk","deviceName":"T7G5T15427004998","platformName":"Android","appActivity":"com.bill99.kuaiqian.ui.base.WelcomeActivity","noSign":true,"appPackage":"com.bill99.kuaiqian"},"sessionId":"80a6ad1b-ed9d-4b75-be4e-31996205002f"} > info: <-- GET /wd/hub/session/80a6ad1b-ed9d-4b75-be4e-31996205002f 200 2.362 ms - 862 {"status":0,"value":{"platform":"LINUX","browserName":"Android","platformVersion":"5.0.1","webStorageEnabled":false,"takesScreenshot":true,"javascriptEnabled":true,"databaseEnabled":false,"networkConnectionEnabled":true,"locationContextEnabled":false,"warnings":{},"desired":{"app":"D:\\software\\adt-bundle-windows\\sdk\\platform-tools\\app_installed\\kuaiqianqianbaoapp.apk","deviceName":"HUAWEI GRA-UL00","platformName":"Android","appActivity":"com.bill99.kuaiqian.ui.base.WelcomeActivity","noSign":true,"appPackage":"com.bill99.kuaiqian"},"app":"D:\\software\\adt-bundle-windows\\sdk\\platform-tools\\app_installed\\kuaiqianqianbaoapp.apk","deviceName":"T7G5T15427004998","platformName":"Android","appActivity":"com.bill99.kuaiqian.ui.base.WelcomeActivity","noSign":true,"appPackage":"com.bill99.kuaiqian"},"sessionId":"80a6ad1b-ed9d-4b75-be4e-31996205002f"} > info: --> POST /wd/hub/session/80a6ad1b-ed9d-4b75-be4e-31996205002f/element {"using":"id","value":"com.bill99.kuaiqian:id/q9"} > info: [debug] Waiting up to 0ms for condition > info: [debug] Pushing command to appium work queue: ["find",{"strategy":"id","selector":"com.bill99.kuaiqian:id/q9","context":"","multiple":false}] > info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"find","params":{"strategy":"id","selector":"com.bill99.kuaiqian:id/q9","context":"","multiple":false}} > info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION > info: [debug] [BOOTSTRAP] [debug] Got command action: find > info: [debug] [BOOTSTRAP] [debug] Finding com.bill99.kuaiqian:id/q9 using ID with the contextId: multiple: false > info: [debug] [BOOTSTRAP] [debug] Using: UiSelector[INSTANCE=0, RESOURCE_ID=com.bill99.kuaiqian:id/q9] > info: [debug] [BOOTSTRAP] [debug] Returning result: {"status":0,"value":{"ELEMENT":"1"}} > info: [debug] Responding to client with success: {"status":0,"value":{"ELEMENT":"1"},"sessionId":"80a6ad1b-ed9d-4b75-be4e-31996205002f"} > info: <-- POST /wd/hub/session/80a6ad1b-ed9d-4b75-be4e-31996205002f/element 200 585.720 ms - 87 {"status":0,"value":{"ELEMENT":"1"},"sessionId":"80a6ad1b-ed9d-4b75-be4e-31996205002f"} > info: --> GET /wd/hub/session/80a6ad1b-ed9d-4b75-be4e-31996205002f/element/1/text {} > info: [debug] Pushing command to appium work queue: ["element:getText",{"elementId":"1"}] > info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"element:getText","params":{"elementId":"1"}} > info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION > info: [debug] [BOOTSTRAP] [debug] Got command action: getText > info: [debug] [BOOTSTRAP] [debug] Returning result: {"status":0,"value":"鐞嗚储"} > info: [debug] Responding to client with success: {"status":0,"value":"鐞嗚储","sessionId":"80a6ad1b-ed9d-4b75-be4e-31996205002f"} > info: <-- GET /wd/hub/session/80a6ad1b-ed9d-4b75-be4e-31996205002f/element/1/text 200 193.723 ms - 80 {"status":0,"value":"鐞嗚储","sessionId":"80a6ad1b-ed9d-4b75-be4e-31996205002f"} > info: --> POST /wd/hub/session/80a6ad1b-ed9d-4b75-be4e-31996205002f/element/1/click {"id":"1"} > info: [debug] Pushing command to appium work queue: ["element:click",{"elementId":"1"}] > info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"element:click","params":{"elementId":"1"}} > info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION > info: [debug] [BOOTSTRAP] [debug] Got command action: click > info: [debug] [BOOTSTRAP] [debug] Returning result: {"status":0,"value":true} > info: [debug] Responding to client with success: {"status":0,"value":true,"sessionId":"80a6ad1b-ed9d-4b75-be4e-31996205002f"} > info: <-- POST /wd/hub/session/80a6ad1b-ed9d-4b75-be4e-31996205002f/element/1/click 200 3808.115 ms - 76 {"status":0,"value":true,"sessionId":"80a6ad1b-ed9d-4b75-be4e-31996205002f"} > info: --> DELETE /wd/hub/session/80a6ad1b-ed9d-4b75-be4e-31996205002f {} > info: Shutting down appium session > info: [debug] Pressing the HOME button > info: [debug] executing cmd: D:\software\sdk\platform-tools\adb.exe -s T7G5T15427004998 shell "input keyevent 3" > info: [debug] Stopping logcat capture > info: [debug] Logcat terminated with code null, signal SIGTERM > info: [debug] Sent shutdown command, waiting for UiAutomator to stop... > info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"shutdown"} > info: [debug] [BOOTSTRAP] [debug] Got command of type SHUTDOWN > info: [debug] [BOOTSTRAP] [debug] Returning result: {"status":0,"value":"OK, shutting down"} > info: [debug] [UIAUTOMATOR STDOUT] [CDS]close[4724] > info: [debug] [UIAUTOMATOR STDOUT] close [socket][/0.0.0.0:4724] > info: [debug] [BOOTSTRAP] [debug] Closed client connection > info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: numtests=1 > info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: stream=. > info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: id=UiAutomatorTestRunner > info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: test=testRunServer > info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: class=io.appium.android.bootstrap.Bootstrap > info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: current=1 > info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS_CODE: 0 > info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: stream= > info: [debug] [UIAUTOMATOR STDOUT] Test results for WatcherResultPrinter=. > info: [debug] [UIAUTOMATOR STDOUT] Time: 23.808 > info: [debug] [UIAUTOMATOR STDOUT] OK (1 test) > info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS_CODE: -1 > info: [debug] UiAutomator shut down normally > info: [debug] Cleaning up android objects > info: [debug] Cleaning up appium session > info: [debug] Responding to client with success: {"status":0,"value":null,"sessionId":"80a6ad1b-ed9d-4b75-be4e-31996205002f"} > info: <-- DELETE /wd/hub/session/80a6ad1b-ed9d-4b75-be4e-31996205002f 200 1154.180 ms - 76 {"status":0,"value":null,"sessionId":"80a6ad1b-ed9d-4b75-be4e-31996205002f"}
tips:获取appPackage和appActivity。最直接的方法就是用appium.
或者运行cmd,到sdk的build-tools目录下,输入aapt d badging D:\software\adt-bundle-windows\sdk\platform-tools\app_installed\kuaiqianqianbaoapp.apk|findstr "package launchable-activity"
参考:
安装环境参考:http://www.cnblogs.com/puresoul/p/4696638.html