环境准备:
Mac*1、iOS真机—*1、iOS dev*1测试包、数据线*1(已绑开发者证书)
软环境:
JDK1.8、Maven3+、XCode8+、Nodejs@latest、Appium@latest
软工具:
homebrew,Intellij IDEA or Eclipse
注:jdk、Maven安装及环境变量配置网上很多成熟的解决方案,这里不多赘述。
XCode直接在apple Store下载。
 
Steps:
1.安装hombrew
打开终端,输入以下命令并回车
/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.安装npm及cnpm

brew install -g node

npm install -g cnpm --registry=https://registry.npm.taobao.org
 
5.安装ios-deploy
cnpm install -g ios-deploy

注:如果报错stderr: xcode-select: error: tool 'xcodebuild' requires Xcode, but active developer directory '/Library/Developer/CommandLineTools' is a command line tools instance

,执行sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer

原因:Xcode安装路径非系统指定路径。

 

6.安装xcpretty

gem install xcpretty

 

7.通过npm install -g 安装以下依赖

babel-eslint@^7.1.1

eslint@^3.10.2

eslint-plugin-import@^2.2.0

eslint-plugin-mocha@^4.7.0

eslint-plugin-promise@^3.3.1

 

8.安装appium-xcuitest-driver

npm install -g appium-xcuitest-driver

 

9.配置appium-xcuitest-driver依赖

cd  /usr/local/lib/node_modules/appium-xcuitest-driver/WebDriverAgent (如果WebDriverAgent 所在路径和此不同,请自行查找)
mkdir -p Resources/WebDriverAgent.bundle
sh ./Scripts/bootstrap.sh

 

10.编译WebDriverAgent  【复杂&重要】

cd  /usr/local/lib/node_modules/appium-xcuitest-driver/WebDriverAgent

open WebDriverAgent.xcodeproj

如果装过xcode会直接打开为一个工程

更改开发者签名项,改为公司开发者。

编译WebDriverAgentLib

编译WebDriverAgentRunner

build成功后关闭XCode

注:WebDriverAgent的项目源码:https://github.com/facebook/WebDriverAgent/apple,感兴趣可以自己研究下

 

11.建立WebDriverAgent服务(手机和MAC都在同一个网段下,且都能连接外网)

将WebDriverAgentRunner编译到手机上:

cd  /usr/local/lib/node_modules/appium-xcuitest-driver/WebDriverAgent
xcodebuild -project WebDriverAgent.xcodeproj -scheme WebDriverAgentRunner -destination 'id=udid4phone' test

( idevice_id --list 命令,可以查看当前连接的所有手机udid )

 

12.安装appium

npm install -g appium

安装完成后,打开终端执行:appium测试是否成功

 

13.安装appium-desktop 客户端

appium.io 找downloads,自行下载。

 
posted on 2018-07-16 16:51  王小洋err  阅读(105)  评论(0)    收藏  举报