之前公司需要搭建一款Appium的ios测试环境,网上的也有不少相关教程,但是都基本都是早期的版本,此次将会使用最新版的·Appium Desktop 1.15.0
来总结此次搭建途中遇到的坑,希望可以帮助后面需要搭建此环境的同学们。
1.15.0
,Appium-Desktop 如下图所示:mac os
平台的 appium,然后进行一路Next
安装即可。10.14.6
如下图所示:mac catalina
,笔者在此系统上遇到xcode编译项目失败的问题,而此版本的macos的xcode不存在此问题,因此下载此版本对应的Xcode版本即可,首先进入链接https://developer.apple.com/download/more/ 进入页面并使用apple id
登录后可以看到如下画面:Xcode 10.3
以及对应版本的Command line Tools for Xcode
如下图所示:Xcode 10.3.xip
解压后的程序移动到mac的应用程序目录即可,然后在安装dmg文件。/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
AppiumDesktop
是用Node.js
编写的服务器,所以需要安装node。若你的电脑安装有brew
环境直接输入下面命令行即可进行node
的安装。brew install node
完成执行node -v,查看安装node版本:
其中 NPM
是Node.js
包管理工具,下载安装Node.js
会自动安装NPM
,可以查看一下NPM
的版本:
brew install git
brew install carthage
sudo npm install appium-doctor -g
安装完成后,终端输入下面命令以检查appium所需要的环境是否齐全。
appium-doctor
这里有报错提升是由于安装是基于IOS版本的,所以android的SDK环境暂未下载。需要注意的是:网上有很多关于Face book
的WebDriverAgent
项目,但是这些项目已经很老且很久没有维护,而且存在很多的问题。这里推荐使用Appium Desktop
自带的WebDriverAgent
项目即可,打开Appium-Desktop的WebDriverAgent
项目的路径
目录如下所示:
/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/appium-webdriveragent
将目录copy到桌面。进入WebDriverAgent
项目的根目录下执行下面命令:
# 进入到WDA 根目录
cd WebDriverAgent/
# 运行初始化脚本
./Scripts/bootstrap.sh
brew install ideviceinstaller
npm install -g ios-deploy
查看连接的设备:
ios-deploy -c
上面的环境搭建好后,打开桌面的appium-webdriveragent
的WebDriverAgent.xcodeproj
文件
打开后需要做的就是配置Xcode
的account
添加你的apple Id
,可以通过下面操作进行配置如下图所示:
The app ID "com.facebook.WebDriverAgentRunner" cannot be registered
to your development team. Change your bundle identifier
to a unique string to try again.
解决方法:WebDriverAgentRunner -> Build Settings设置中,找到Packaging中的选项,将其内容修改为唯一识别的字符串。
修改完毕后就不报错了。
Proudct->Test
如下图所示:注意问题:This iPhone 7 (Model 1660, 1778, 1779, 1780) is running iOS 13.1.2 (17A860), which may not be supported by this version of Xcode.
如下图所示:/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport
下,如下图所示:Product->Test
运行完成可能会报以下的错误:This application’s application-identifier entitlement does not match that of the installed application. These values must match for an upgrade to be allowed.
这是因为手机已经存在了一个WebDriverRunner
,删除了app重新在运行就好,再次运行就会报以下错误。
Verify the Developer App certificate for your account is trusted on your device. Open Settings on iPhone and navigate to General -> Device Management, then select your Developer App certificate to trust it.Internal launch error: process launch failed: Security
解决方法:设置=》通用=》设备管理=》开发者应用=》验证应用 如下图所示:
点击信任即可如下图所示:
先删除之前的运行的 Product->Clean Build Folder, 再次运行Product->Test。
brew install libimobiledevice --HEAD
安装后可能报下面的这个错误:
原因是:由于系统要求的libusbmuxd 版本和所要安装的版本不一致的问题导致的,可使用下面命令进行解决。
brew uninstall --ignore-dependencies libimobiledevice
brew uninstall --ignore-dependencies usbmuxd
brew install --HEAD usbmuxd
brew unlink usbmuxd
brew link usbmuxd
brew install --HEAD libimobiledevice
打开控制台方法:选择view->Debug Area->Activate console打开底部控制台。然后控制台会输出IP地址和端口,例如:http://127.0.0.1:8100/status,输入在浏览器中,确认WDA是否运行成功,页面刷新出不来,再次输入下面命令开启代理:
iproxy 8100 8100
Edit Configuration
配置以下环境变量,如下图所示:idevice_id -l
即可获取,而bundleId可以通过输入命令:ideviceinstaller -l
出现如下图列表:更多配置请参考:https://github.com/appium/appium/blob/master/docs/en/writing-running-appium/caps.md
配置完成后点击Start Session
的时候报端口占用的错误如下图所示:
解决方法:重启appium-desktop软件编辑修改ios的WebDriverAgent的端口号入下图所示:
设置完成后在重新Start Session
如果可以看到下面的页面就证明安装已经成功。