Dev::Coder 在電梯裡遇見雙胞胎
首頁 | 關於我 | 筆記 // 當你開始尋找,你就已經在前往的路上...

首先確認有沒有安裝 Node.js(因為 Appium 是用它開發的),接著安裝 appium 套件,官方首頁這麼寫著:

> sudo npm install -g appium # 1
> npm install wd             # 2
> appium &
> node your-appium-test.js
1 安裝 appium 套件(-g, global installation),之後方便調用 appium 來啟動 Appium server
2 安裝 wd (WebDriver/Selenium 2 node.js client) 套件?
Note 其實這個動作並非必要,除非你要用 Node.js 來寫 Appium 的測試。如果要用其他語言來寫測試的話,就要安裝不同的 language bindings

以下是安裝兩個套件的過程:(假設 Node.js 安裝時採用 --prefix=~/local

$ npm install -g appium
npm http GET https://registry.npmjs.org/appium
...
~/local/bin/appium -> ~/local/lib/node_modules/appium/app/bin.js 1
~/local/bin/instruments_client -> ~/local/lib/node_modules/appium/instruments/client_bin.js
~/local/bin/authorize_ios -> ~/local/lib/node_modules/appium/app/authorize.js
...
appium@0.7.3 ~/local/lib/node_modules/appium
├── path@0.4.9
...
└── socket.io@0.9.16 (base64id@0.1.0, policyfile@0.0.4, redis@0.7.3, socket.io-client@0.9.16)

$ npm install wd
...
wd@0.0.32 node_modules/wd
├── vargs@0.1.0
...
└── request@2.21.0 (json-stringify-safe@4.0.0, aws-sign@0.3.0, forever-agent@0.5.0...)
1 安裝過後多了 appiuminstruments_clientauthorize_ios 三個 commands 可用。

試著啟動 Appium server,確認安裝沒有問題:

$ appium
info: Welcome to Appium v0.7.3 (REV 120bb6813272efc128276bd212202e2cda0dea14)
info: Appium REST http interface listener started on 0.0.0.0:4723
   info  - socket.io started

從 Source Code 安裝 Appium

另外,Running Appium on Linux 系列文件(另外還有 Mac OS X 跟 Windows 的版本)提到另一種從 source code 安裝的方式。

$ cd /tmp
$ git clone https://github.com/appium/appium.git # 1
$ cd appium

$ ./reset.sh --android --dev # 2
---- Resetting / Initializing Appium ----
* Dev mode is on, will download/build test apps
RESETTING NPM
* Installing new or updated NPM modules (including devDeps) 3
RESETTING GENERAL
* Setting git revision data
* Linking git pre-commit hook
RESETTING ANDROID
* Configuring Android bootstrap
* Building Android bootstrap 4
* Building Unlock.apk
* Configuring and cleaning/building Android test app: ApiDemos   2
* Attempting to uninstall android app com.example.android.apis
* Configuring and cleaning/building Android test app: ToggleTest
* Attempting to uninstall android app com.example.toggletest
* Downloading gps demo                                           2
* Setting Android config to Appium's version
RESETTING CHROMEDRIVER
* Finding latest version
* Determining platform
* Downloading ChromeDriver version 2.9 for linux
* Unzipping ChromeDriver
CLEANING UP
* Cleaning any temp files
* Setting build time and SHA info
---- reset.sh completed successfully ----

$ tree sample-code/ -L 2
sample-code/
├── apps
│   ├── ApiDemos -> /tmp/appium/submodules/ApiDemos 2
│   ├── ContactManager
│   ├── gps-demo                                    2
│   ├── gps-demo.zip                                2
│   ├── RobotCalibration
│   ├── TestApp
│   └── WebViewApp
└── examples
    ├── dotnet
    ├── java
    ├── node
    ├── php
    ├── python
    └── ruby
1 從 GitHub 直接取出 Appium 的 source code。
2 透過 ./reset.sh 完成 appium 套件的安裝,另外加上 --dev 才會產生 ApiDemos 跟 gps-demo 這兩個 example tests 會用到的 apps。
3 從 source code 安裝 Appium (local installation)。
4 產生控制 Android 會用到的 bootstrap.jar

透過 source code 安裝,大致上就是比透過 npm 直接安裝套件多出 sample code 跟 apps,還有啟動 server 的方式不同:

$ node server.js
info: Welcome to Appium v0.7.3 (REV 120bb6813272efc128276bd212202e2cda0dea14)
info: Appium REST http interface listener started on 0.0.0.0:4723
   info  - socket.io started

覺得這份文件有幫助?別忘了按個讚並分享給更多的人、留下你/您的意見...

comments powered by Disqus