iOS自动化测试环境搭建

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/solojy2012/article/details/82345038

1 环境准备

1.1 Mac os x

1.2 brew 

Mac os x的包管理工具,安装方法:终端输入:

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

检验安装:brew -v

1.3 xcode 

app store中下载安装

1.4 node

终端:brew install node 安装

检查安装:node –v

1.5 wd

npm install wd

检验安装npm wd -v

1.6 Appium Desktop 安装

传送门:http://appium.io/downloads.html

2 运行Appium Desktop

可单独配置Android_home和java_home

关于iOS session的具体参数配置,参照https://github.com/appium/appium/blob/master/docs/en/writing-running-appium/caps.md

启动成功如截图所示:

3 appium desktop真机调试(个人开发者)

3.1 WebDriverAgent(WDA)的签名设置

使用xcode打开appium目录下的WDA中的WebDriverAgent.xcodeproj

/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/appium-xcuitest-driver/WebDriverAgent

step1 更改WebDriverAgentLib

step2 更改WebDriverAgentRunner

step3 更改WebDriverRunner的Build Settings

3.2 配置capabilities启动session即可

如 启动真机iPhone7 iOS 11.4.1中的支付宝app设置如下:

{
  "platformName": "iOS",
  "platformVersion": "11.4.1",
  "deviceName": "iPhone 7",
  "automationName": "XCUITest",
  "app": "com.alipay.iphoneclient",
  "udid": "pls relaced with ur device's udid",
  "noReset": true
}

可能遇到的问题:

1.Unable to launch WebDriverAgent because of xcodebuild failure: "Carthage binary is not found. Install using `brew install carthage` if it is not installed and make sure the root folder, where carthage binary is installed, is present in PATH environment variable

解决办法:brew install carthag  

2.[XCUITest] The 'idevice_id' program is not installed. If you are running a real device test it is necessary. Install with 'brew install libimobiledevice --HEAD'

解决办法:brew install libimobiledevice --HEAD

3.[XCUITest] Error: Could not initialize ios-deploy make sure it is installed (npm install -g ios-deploy) and works on your system.

解决办法:npm install -g ios-deplo

4.Unable to launch WebDriverAgent because of xcodebuild failure: "xcodebuild failed with code 65". Make sure you follow the tutorial at https://github.com/appium/appium-xcuitest-driver/blob/master/docs/real-device-config.md. Try to remove the WebDriverAgentRunner application from the device if it is installed and reboot the device

解决办法:https://testerhome.com/topics/8533

注:如果还是报此错误,请先在通用>>设备管理>>开发者应用 中信任当前证书

参考:

1.Appium自动化—浅谈iOS自动化测试环境搭建

https://www.jianshu.com/p/c43a94ecca97

2.iOS真机调试

https://jingyan.baidu.com/article/358570f6b3f4f4ce4724fc0a.html

3.Setting up iOS Real Devices Tests with XCUITest 

https://github.com/appium/appium-xcuitest-driver/blob/master/docs/real-device-config.md

猜你喜欢

转载自blog.csdn.net/solojy2012/article/details/82345038