Appium 是一个自动化测试开源工具,支持 iOS 平台和 Android 平台上的原生应用,web 应用和混合应用。node
本次环境配置相关:
macOS:10.13.4
Appium-desktop:1.6.1
Xcode:9.3.1
---ios
一、 安装homebrew:git
$ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"github
二、 安装libimobiledevice:web
$ brew install libimobiledevice --HEADnpm
三、 安装carthage:bootstrap
$ brew install carthagexcode
四、安装node:ruby
$ brew install nodeapp
五、安装npm:
$ brew install npm
六、安装ios-deploy:
$ npm install -g ios-deploy
八、安装xcpretty:
$ gem install xcpretty
九、安装appium,appium-doctor
进入官网,下载Appium-1.6.1.dmg,安装便可。
固然你能够使用命令:npm install -g appium来安装appium,可是后面就会各类报错!!(别问我是怎么知道的,我搞了2天。)
$ npm install -g appium-doctor
十、使用appium-doctor 检查Appium iOS环境环境
appium-doctor --ios
info AppiumDoctor Appium Doctor v.1.4.3 info AppiumDoctor ### Diagnostic starting ### info AppiumDoctor ✔ The Node.js binary was found at: /usr/local/bin/node info AppiumDoctor ✔ Node version is 10.1.0 info AppiumDoctor ✔ Xcode is installed at: /Applications/Xcode.app/Contents/Developer info AppiumDoctor ✔ Xcode Command Line Tools are installed. info AppiumDoctor ✔ DevToolsSecurity is enabled. info AppiumDoctor ✔ The Authorization DB is set up properly. info AppiumDoctor ✔ Carthage was found at: /usr/local/bin/carthage info AppiumDoctor ✔ HOME is set to: /Users/wangjuan info AppiumDoctor ### Diagnostic completed, no fix needed. ### info AppiumDoctor info AppiumDoctor Everything looks good, bye! info AppiumDoctor
一、进入appium安装目录下WebDriverAgent文件夹,具体路径参照本身的路径,能够经过find命令查找
cd /Applications/Appium.app/Contents/Resources/app
/node_modules/appium/node_modules/appium-xcuitest-driver/WebDriverAgent
二、在WebDriverAgent目录下执行如下命令
mkdir -p Resources/WebDriverAgent.bundle
sh ./Scripts/bootstrap.sh
三、编译WebDriverAgent.xcodeproj
Xcode打开当前目录下的WebDriverAgent.xcodeproj文件
注意⚠️:进入项目后要编辑一些内容,请无比按照步骤所有修改。步骤见下图!!
一、TARGETS->WebDriverAgentLib的Bundle Identifier更改成本身命名的Identifier。(全部Identifier注意保持一致!!)
二、TARGETS->WebDriverAgentLib的Signing选择使用我的的证书。
三、TARGETS->WebDriverAgentRunner的Signing选择使用我的的证书。
四、PROJECT->WebDriverAgent的Product Bundle Identifier更改成本身命名的Identifier。(全部Identifier注意保持一致!!)
五、TARGETS->WebDriverAgentLib的Product Bundle Identifier更改成本身命名的Identifier。(全部Identifier注意保持一致!!)
六、TARGETS->WebDriverAgentRunner的Product Bundle Identifier更改成本身命名的Identifier。(全部Identifier注意保持一致!!)
七、Device选择已链接的测试机
八、点击build按钮来测试,按照步骤设置后,可build succeeded~
九、测试机上安装证书,执行如下命令:
xcodebuild -project WebDriverAgent.xcodeproj -scheme WebDriverAgentRunner -destination 'id=测试机的udid' test
若是没有报错证实安装成功,同时手机上会安装一个WebDriverAgent软件。须要在手机设置->通用->设备管理->信任开发者。以下图:
Appium Client有Ruby,Python,Java三个版本,可自行选择本身喜欢的安装便可,本次只针对Python版安装:
pip install Appium-Python-Client
以上,接下来能够定位元素,推荐使用App Inspector,开始iOS自动化之旅吧~~