Mac下搭建Appium+Python3+iOS 真机运行环境搭建

Song1418 次浏览0个评论2020年12月22日

Appium 是一个自动化测试开源工具,支持 iOS 平台和 Android 平台上的原生应用,web 应用和混合应用。

本次环境配置相关:
macOS:10.13.4
Appium-desktop:1.6.1
Xcode:9.3.1

一、环境配置

1、 安装homebrew:

$ /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:

$ brew install node

5、安装npm:

$ brew install npm

6、安装ios-deploy:

$ npm install -g ios-deploy

8、安装xcpretty:

$ gem install xcpretty

9、安装appium,appium-doctor

进入appium github官网下载Appium-mac-1.20.0-beta.0.dmg ,安装即可。

然后安装appium-doctor

$ npm install -g appium-doctor

10、使用appium-doctor 检查Appium iOS环境环境

appium-doctor --ios

info AppiumDoctor Appium Doctor v.1.15.4
info AppiumDoctor ### Diagnostic for necessary dependencies starting ###
info AppiumDoctor  ✔ The Node.js binary was found at: /usr/local/bin/node
info AppiumDoctor  ✔ Node version is 14.2.0
info AppiumDoctor  ✔ Xcode is installed at: /Applications/Xcode.app/Contents/Developer
info AppiumDoctor  ✔ Xcode Command Line Tools are installed in: /Applications/Xcode.app/Contents/Developer
info AppiumDoctor  ✔ DevToolsSecurity is enabled.
info AppiumDoctor  ✔ The Authorization DB is set up properly.
info AppiumDoctor  ✔ Carthage was found at: /usr/local/bin/carthage. Installed version is: 0.34.0
info AppiumDoctor  ✔ HOME is set to: /Users/songlu
info AppiumDoctor ### Diagnostic for necessary dependencies completed, no fix needed. ###
info AppiumDoctor 
info AppiumDoctor ### Diagnostic for optional dependencies starting ###
WARN AppiumDoctor  ✖ opencv4nodejs cannot be found.
WARN AppiumDoctor  ✖ ffmpeg cannot be found
WARN AppiumDoctor  ✖ mjpeg-consumer cannot be found.
WARN AppiumDoctor  ✖ set-simulator-location is not installed
WARN AppiumDoctor  ✖ idb and idb_companion are not installed
WARN AppiumDoctor  ✖ applesimutils cannot be found
info AppiumDoctor  ✔ ios-deploy is installed at: /usr/local/bin/ios-deploy. Installed version is: 1.11.3
info AppiumDoctor ### Diagnostic for optional dependencies completed, 6 fixes possible. ###
info AppiumDoctor 
info AppiumDoctor ### Optional Manual Fixes ###
info AppiumDoctor The configuration can install optionally. Please do the following manually:
WARN AppiumDoctor  ➜ Why opencv4nodejs is needed and how to install it: https://github.com/appium/appium/blob/master/docs/en/writing-running-appium/image-comparison.md
WARN AppiumDoctor  ➜ ffmpeg is needed to record screen features. Please read https://www.ffmpeg.org/ to install it
WARN AppiumDoctor  ➜ mjpeg-consumer module is required to use MJPEG-over-HTTP features. Please install it with 'npm i -g mjpeg-consumer'.
WARN AppiumDoctor  ➜ set-simulator-location is needed to set location for Simulator. Please read https://github.com/lyft/set-simulator-location to install it
WARN AppiumDoctor  ➜ Why idb is needed and how to install it: https://github.com/appium/appium-idb
WARN AppiumDoctor  ➜ Why applesimutils is needed and how to install it: http://appium.io/docs/en/drivers/ios-xcuitest/
info AppiumDoctor 
info AppiumDoctor ###
info AppiumDoctor 
info AppiumDoctor Bye! Run appium-doctor again when all manual fixes have been applied!
info AppiumDoctor 

二、安装WebDriverAgent

1、找到appium-webdriveragent

找到appium的安装路径,进入到appium安装路径下的webdriveragent目录,如果是命令行安装的appium,完整路径通常为:

cd /usr/local/lib/node_modules/appium/node_modules/appium-webdriveragent

# 执行如下命令
./Scripts/bootstrap.sh

执行前请确保你已经安装了Carthage,原因在于carthage会安装WDA需要的相关依赖。

\3.jpg

2、打开appium目录下的WebDriverAgent.xcodeproj

在命令行执行如下命令用Xcode打开刚才创建的WDA的工程文件。

open /usr/local/lib/node_modules/appium/node_modules/appium-webdriveragent/WebDriverAgent.xcodeproj

如果出现The file “project.xcworkspace” could not be unlocked.问题,则参考 WebDriverAgent 真机安装教程 即可解决。

注意:进入项目后要编辑一些内容,请无比按照步骤全部修改。步骤见下图!!

1、TARGETS->WebDriverAgentLib的Bundle Identifier更改为自己命名的Identifier。(所有Identifier注意保持一致!!)

2、TARGETS->WebDriverAgentLib的Signing选择使用个人的证书。

3、TARGETS->WebDriverAgentRunner的Signing选择使用个人的证书。

4、PROJECT->WebDriverAgent的Product Bundle Identifier更改为自己命名的Identifier。(所有Identifier注意保持一致!!)

5、TARGETS->WebDriverAgentLib的Product Bundle Identifier更改为自己命名的Identifier。(所有Identifier注意保持一致!!)

6、TARGETS->WebDriverAgentRunner的Product Bundle Identifier更改为自己命名的Identifier。(所有Identifier注意保持一致!!)

7、Device选择已连接的测试机

8、点击build按钮来测试,按照步骤设置后,可build succeeded~

9、测试机上安装证书,执行以下命令: xcodebuild -project WebDriverAgent.xcodeproj -scheme WebDriverAgentRunner -destination 'id=测试机的udid' test

如果没有报错证明安装成功,同时手机上会安装一个WebDriverAgent软件。需要在手机设置->通用->设备管理->信任开发者。如下图:

参考:

提交评论

请登录后评论

用户评论

    当前暂无评价,快来发表您的观点吧...

更多相关好文

    当前暂无更多相关好文推荐...