python连接苹果手机_Mac下搭建Appium+Python3+iOS 真机运行环境搭建

本文详细介绍了如何在Mac上搭建Appium+Python3的iOS真机运行环境,包括安装Homebrew、libimobiledevice、carthage、node、npm、ios-deploy等工具,以及配置WebDriverAgent的过程,确保自动化测试所需环境的完善。
摘要由CSDN通过智能技术生成

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-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需要的相关依赖。

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软件。需要在手机设置->通用->设备管理->信任开发者。如下图:

参考:

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值