Appium 源碼安裝環境配置 iOS篇

來源:互聯網
上載者:User

標籤:個人   local   index   ase   錯誤   介紹   自己   UI   使用   

一、安裝環境介紹
  • macOS 10.12.4 

  • Xcode 8.3.2

  • 適用機型:iOS9 及以上機型

     

二、Appium源碼安裝

Xcode升級8.2之後不再支援UIAutomation,轉而使用XCUITest;故當Xcode版本為8.2及以上版本時,只能安裝Appium 1.5.3之後版本。Appium 1.5.3是基於UIAutomation底層驅動,即使安裝成功也無法正常使用。

在實際安裝過程中出現過Appium 1.6.3版本安裝一直失敗的情況,故以下以1.6.4-beta版本為例。但也可以嘗試安裝1.6.3版本,建議優先選擇正式版本安裝。

同時1.5.3之後的版本沒有圖形介面版本,故使用源碼安裝。

1、安裝brew

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

2、安裝libimobiledevice

brew install libimobiledevice --HEAD

3、安裝carthage

brew install carthage

4、安裝node.js 

進入 https://nodejs.org/en/download/ 下載.pkg並安裝

5、安裝cnpm

npm install -g cnpm --registry=https://registry.npm.taobao.org

6、安裝ios-deploy 

cnpm install -g ios-deploy

7、安裝xcpretty

gem install xcpretty

8、卸載原有Appium

$ npm uninstall appium -g
$ npm cache clean

9、安裝Appium

$ npm i -g [email protected]

10、查看安裝情況

$ appium -v(出現版本號碼即安裝成功)

11、安裝appium-doctor

$ npm i -g appium-doctor 

12、檢查Appium環境

$ appium-doctor

當全為√時,Appium安裝後後環境一切正常,若出現問題請參考下面的問題匯總

13、安裝RoutingHttpServer庫

背景:安裝Appium後會有一個WebDriverAgent的iOS App工程,但未安裝RoutingHttpServer庫時無法編繹通過

$ cd /usr/local/lib/node_modules/appium/node_modules/appium-xcuitest-driver/WebDriverAgent
$ mkdir -p Resources/WebDriverAgent.bundle
$ sh ./Scripts/bootstrap.sh -d

14、WebDriverAgent工程配置(a)Xcode開啟 WebDriverAgent.xcodeproj 工程

目錄:/usr/local/lib/node_modules/appium/node_modules/appium-xcuitest-driver/WebDriverAgent)

(b)修改iOS Deployment Target 為iOS 9.0

若不修改僅支援9.3以上版本

 

需修改project、所有targets中相應參數

(c)修改BundlID(必須修改,不能使用預設值)

 修改5個targets中的 Product Bundle Identifier 參數

      1. 個人賬戶(不付費賬戶):可以按自己的需求修改

      2. 企業賬戶(付費賬戶):若使用公司的賬戶,需修改為特定的值(請聯絡我)

(d)編繹工程

編繹WebDriverAgentLib、WebDriverAgentRunner、WebDriverAgentRunner-nodebug、IntegrationApp;全部編繹通過,即工程配置完成;

(e)啟動Appium 服務

$ appium -a 127.0.0.1 -p 4723

(f)校正Appium服務是否可用

$ xcodebuild -project /usr/local/lib/node_modules/appium/node_modules/appium-xcuitest-driver/WebDriverAgent/WebDriverAgent.xcodeproj -scheme WebDriverAgentRunner -destination id=裝置UDID test

出現如下內容,則服務可用:

Test Case ‘-[UITestingUITests testRunner]‘ started.
   t =     0.00s     Start Test at 2017-05-09 21:49:32.939
   t =     0.01s     Set Up
2017-05-09 21:49:32.968 XCTRunner[663:156885] Built at May  9 2017 21:49:21
2017-05-09 21:49:33.006 XCTRunner[663:156885] ServerURLHere->http://10.1.17.177:8100<-ServerURLHere 

三、問題匯總1、appium-doctor:Xcode Command Line Tools 未安裝

xcode-select --install

2、appium-doctor:adb、android未找到(a)建議安裝android ADT(http://tools.android-studio.org/index.php/adt-bundle-plugin)下載後直接解壓就可以使用(b)配置環境變數

1. 開啟 .bash_profile檔案

$ cd ~
$ open -e .bash_profile

2. 添加如下內容:

其中/Users/XXX/Documents/1--XXX/Automation/adt-bundle-mac-x86_64-20131030為ADT解壓後的目錄

export PATH=${PATH}:/Users/XXX/Documents/1--XXX/Automation/adt-bundle-mac-x86_64-20131030/sdk/platform-tools
export PATH=${PATH}:/Users/XXX/Documents/1--XXX/Automation/adt-bundle-mac-x86_64-20131030/sdk/tools
export ANDROID_HOME="/Users/XXX/Documents/1--XXX/Automation/adt-bundle-mac-x86_64-20131030/sdk"
export PATH=${PATH}:/Users/XXX/Documents/1--XXX/Automation/adt-bundle-mac-x86_64-20131030/sdk/tools:/Users/XXX/Documents/1--XXX/Automation/adt-bundle-mac-x86_64-20131030/sdk/platform-tools:/$JAVA_HOME/bin

3. 儲存並關閉 .bash_profile檔案

4. 更新配置的環境變數

source .bash_profile

(c)appium-doctor:JavaHome 環境

1. mac 一般內建安裝了JAVA,可以先嘗試配置環境變數

2. 在.bash_profile檔案中添加如下內容

export JAVA_HOME=/usr

3. 若仍有問題,嘗試重新安裝

(d)code: 65, signal: null;code: null, signal: SIGKILL

一般在【二、步驟16】 檢驗時報錯誤:

>> xctest-client.js:202:14 [master] pid:17430 xctest client exit with code: 65, signal: null
>> xctest-client.js:230:14 [master] pid:17430 iproxy exit with code: null, signal: SIGKILL
>> xctest-client.js:157:16 [master] pid:17430 deviceconsole exit with code: null, signal: SIGKIL

出現此問題的原因基本都是WebDriverAgent工程配置時配置不正確,基本為認證問題,按照【二、步驟14】重新設定工程,保證可以全部編繹通過。

 

四、缺陷
  1. 此版本的Appium,無法使用inspecter擷取控制項資訊(後續會提供app-inspecter進行控制項擷取的方法)

  2. 因WebDriverAgent工程編繹的ipa程式只能安裝在iOS9以上,故無法在iOS7?iOS8上做自動化

 

 

Appium 源碼安裝環境配置 iOS篇

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.