前提是windows系統已安裝如下軟件:node
1.jdk 我裝的是1.8.0python
2.android-sdkandroid
3.python,3.4-3.6git
5.Node.js,v8以上github
6.net framework4.5級以上shell
http://www.javashuo.com/article/p-koiyyrih-bq.html npm
安裝好1-6的軟件,就能夠安裝appium了。bootstrap
Appium必定要如今最新版本!否則會報各類奇怪的錯誤。windows
Appium有三種不一樣的版本:appium server、appium desktop、命令行安裝的appium,這三種只需選一種便可。app
appium server:2015年之後就不更新了,版本低,最後版本是AppiumForWindows_1_4_16_1.zip ;
appium desktop:包含appium server,目前最新版本1.12.1,有界面操做,速度慢;
命令行安裝的appium:運行速度快,適合腳本運行(建議安裝此版本);
2.1.1安裝appium
npm --registry http://registry.npm.taobao.org install appium -g
驗證:cmd輸入appium,下圖表示啓動成功。
2.1.1安裝appium-doctor檢測(可選)
npm --registry http://registry.npm.taobao.org install appium-doctor -g
驗證:cmd輸入appium-doctor
進入官網http://appium.io/,https://github.com/appium/appium-desktop/releases/tag/v1.12.0點擊下載對應操做系統的版本;
雙擊已下載的exe文件便可安裝成功。
https://bitbucket.org/appium/appium.app/downloads/
解壓縮後雙擊appium-installer.exe安裝。
配置環境變量,在系統變量Path中加入appium的.bin路徑,例如:C:\Program Files (x86)\Appium\node_modules\.bin
cmd進入輸入命令:appium-doctor,顯示以下圖表示安裝成功。
Cmd窗口輸入pip install Appium-Python-Client
驗證:cmd輸入 appium -v
到此爲止,appium環境搭建成功!
在手機上打開須要測試的APP,而後在運行sdk的tools的安裝目錄下的ui automator viewer;在打開的窗口中點擊左上角的鏈接設備圖標,中就會出現安卓手機的當前界面
點擊界面元素,查看是否能夠選中當前元素,若是能夠,立刻開始APP自動化之旅吧。
若是不能選中元素,再次點擊左上角的鏈接設備圖標,看是否能夠選中。
若是仍是不行,關閉uiautomatorviewer。cmd窗口輸入adb shell uiautomator runtest AppiumBootstrap.jar -c io.appium.android.bootstrap.Bootstrap -e disableAndroidWatchers false命令,沒報錯的話,再次打開uiautomatorviewer嘗試便可。
若是cmd窗口報data\local\tmp目錄下找不到AppiumBootstrap.jar此類錯誤,則須要更換手機嘗試,最好是安卓版本6.0以上的手機,多試幾個機型,若是沒有測試機,能夠安裝模擬機嘗試。
5.1獲取devices name
手機鏈接電腦,開啓usb調試模式。
在cmd窗口輸入adb devices命令,查看手機設備的name
cmd窗口輸入adb shell dumpsys activity activities命令查看App Activity。下圖