iOS自动化测试| Appium + Python3 + iOS真机环境搭建

论坛 期权论坛 期权     
Test交流圈   2019-7-27 14:31   5113   0
Appium是一个自动化测试开源工具,支持iOS平台和Android平台上的原生应用,web应用和混合应用。
本次环境配置相关:
MacOS的:10.13.4
Appium桌面:1.6.1
Xcode中:9.3.1

一,环境配置
1,安装homebrew:
  1. $ /usr/bin/ruby -e"$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
复制代码
2,安装libimobiledevice:
  1. $ brew installlibimobiledevice --HEAD
复制代码
3,安装carthage:
  1. $ brew install carthage
复制代码
4,安装node:
  1. $ brew install node
复制代码
5,安装npm:
  1. $ brew install npm
复制代码
6,安装ios-deploy:
  1. $ npm install -g ios-deploy
复制代码
7,安装xcpretty:
  1. $ gem install xcpretty
复制代码
8,安装appium,appium-doctor:
进入官网,下载Appium-mac-1.13.0.dmg,安装即可。(下面为下载地址:)
  1. https://github.com/appium/appium-desktop/releases/tag/v1.13.0
复制代码
9,使用appium-doctor 检查Appium ios 环境:
  1. appium-doctor --ios
复制代码
  1. info AppiumDoctor Appium Doctor v.1.4.3
复制代码
  1. info AppiumDoctor ### Diagnostic starting ###
复制代码
  1. info AppiumDoctor   The Node.js binary was found at: /usr/local/bin/node
复制代码
  1. info AppiumDoctor   Node version is 10.1.0
复制代码
  1. info AppiumDoctor   Xcode is installed at: /Applications/Xcode.app/Contents/Developer
复制代码
  1. info AppiumDoctor   Xcode Command Line Tools are installed.
复制代码
  1. info AppiumDoctor   DevToolsSecurity is enabled.
复制代码
  1. info AppiumDoctor   The Authorization DB is set up properly.
复制代码
  1. info AppiumDoctor   Carthage was found at:/usr/local/bin/carthage
复制代码
  1. info AppiumDoctor   HOME is set to: /Users/wangjuan
复制代码
  1. info AppiumDoctor ### Diagnostic completed, no fix needed. ###
复制代码
  1. info AppiumDoctor
复制代码
  1. info AppiumDoctor Everything looks good, bye!
复制代码
  1. info AppiumDoctor
复制代码
二,安装WebDriverAgent
1,进入appium安装目录下WebDriverAgent文件夹,具体路径参照自己的路径,可以通过find命令查找
  1. cd /Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/appium-xcuitest-driver/WebDriverAgent
复制代码
2,在WebDriverAgent目录下执行以下命令:
  1. mkdir -p Resources/WebDriverAgent.bundle
复制代码
  1. sh ./Scripts/bootstrap.sh
复制代码
3,编译WebDriverAgent.xcodeproj

Xcode打开当前目录下的WebDriverAgent.xcodeproj文件


注意:进入项目后要编辑一些内容,请务必按照步骤全部修改。

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、测试机上安装证书,执行以下命令:

  1. xcodebuild -project WebDriverAgent.xcodeproj -scheme WebDriverAgentRunner -destination 'id=测试机的udid' test
复制代码
10,如果没有报错证明安装成功,同时手机上会安装一个WebDriverAgent软件。需要在手机设置->通用->设备管理->信任开发者。如下图:




三,Appium Client端

1,Appium Client有Ruby,Python,Java三个版本,可自行选择自己喜欢的安装即可,本次只针对Python版安装:
  1. pip install Appium-Python-Client
复制代码
分享到 :
0 人收藏
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

积分:5
帖子:1
精华:0
期权论坛 期权论坛
发布
内容

下载期权论坛手机APP