前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >基于Python+appium的ios自动化测试demo(更新中)

基于Python+appium的ios自动化测试demo(更新中)

作者头像
freesan44
发布2018-12-21 15:44:40
3.8K0
发布2018-12-21 15:44:40
举报
文章被收录于专栏:freesan44

appium环境搭建可参考以下两个链接: https://www.jianshu.com/p/a2b79cd8bf38 https://www.jianshu.com/p/3c04e029c3ea

环境配置: carthage: stable 0.31.2 (bottled), HEAD usbmuxd: stable 1.0.10 (bottled), HEAD libimobiledevice: stable 1.2.0 (bottled), HEAD npm 6.4.1 ios-deploy 1.9.4 xcpretty 0.3.0 appium-doctor 1.6.0 Appium v1.9.1 Python 3.7 WebDriverAgent 用GitHub的[https://github.com/facebook/WebDriverAgent ] Xcode10.1

每次真机开发启动顺序: 1.先在终端启动WDA(或者直接用XCode直接【WebDriverAgentRunner】-【testing】也行)

代码语言:javascript
复制
xcodebuild build-for-testing test-without-building -project /usr/local/lib/node_modules/appium/node_modules/appium-xcuitest-driver/WebDriverAgent/WebDriverAgent.xcodeproj -scheme WebDriverAgentRunner -destination id=设备ID test

进行端口转发

代码语言:javascript
复制
iproxy 8100 8100 设备ID
  1. 启动Appium Server

Appium Server.png

配置信息:

代码语言:javascript
复制
  "deviceName": "iPhone 6s",
  "platformName": "ios",
  "udid": "601861ce25a7dae4dc3d12e6f43cd42936XXXXXX",
  "automationName": "XCUITest",
  "xcodeOrgId": "  7GTPKLXXXX",
  "xcodeSigningId": "iPhone Developer",
  "no-reset": true,
  "startIWDP": true,
  "bundleId": "com.XXXXXX"
  1. 通过元素定位器进行定位
  2. python通过appium进行脚本编写

遇到的坑:

  1. 运行安装WebDriverAgent验证是否安装成功:
代码语言:javascript
复制
export DEVICE_URL='http://localhost:8100'
export JSON_HEADER='-H "Content-Type: application/json;charset=UTF-8, accept: application/json"'
curl -X GET $JSON_HEADER $DEVICE_URL/status

代码语言:javascript
复制
http://localhost:8100/status

如果单纯WebDriverAgent运行成功,然后appuim没有反应,可能因为有些国产的iPhone设备通过手机的IP和端口还不能访问,此时需要将手机的端口转发到Mac上 : 终端输入:iproxy 8100 8100 <DeviceUDID>

  1. 如果存在多个版本Xcode,在安装brew包的时候,会出现兼容性问题,可以通过切换来处理
代码语言:javascript
复制
sudo xcode-select --switch /Applications/Xcode9.4.1.app
sudo xcode-select --switch /Applications/Xcode.app
  1. 两个wda模块地址 1、在命令行安装appium的时候已经集成了wda模块
代码语言:javascript
复制
/usr/local/lib/node_modules/appium/node_modules/appium-xcuitest-driver/WebDriverAgent/WebDriverAgent.xcodeproj

2、使用appium desktop的wda模块

代码语言:javascript
复制
/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/appium-xcuitest-driver/WebDriverAgent
  1. 出现报错:A new session could not be created. Details: Appium's IosDriver does not support Xcode version 9.4.1. Apple has deprecated UIAutomation. Use the "XCUITest" automationName capability instead. 解决办法:添加 automationName = XCUITest
  2. 出现报错:An unknown server-side error occurred while processing the command. Original error: Unknown device or simulator UDID 解决办法:安装libimobiledevice
代码语言:javascript
复制
brew install --HEAD libimobiledevice
  1. 出现报错:Requested 'libusbmuxd >= 1.1.0' but version of libusbmuxd is 1.0.10 Consider adjusting the PKG_CONFIG_PATH environment variable if you installed software in a non-standard prefix. Alternatively, you may set the environment variables libusbmuxd_CFLAGS and libusbmuxd_LIBS to avoid the need to call pkg-config. See the pkg-config man page for more details. 解决办法:
代码语言:javascript
复制
brew update
brew uninstall --ignore-dependencies libimobiledevice
brew uninstall --ignore-dependencies usbmuxd
brew install --HEAD usbmuxd
brew unlink usbmuxd
brew link usbmuxd
brew install --HEAD libimobiledevice
  1. 出现报错urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='127.0.0.1', port=4723): Max retries exceeded with url: /wd/hub/session (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x109c28908>: Failed to establish a new connection: [Errno 61] Connection refused')) 解决办法:打开appium-desktop
本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2018.11.30 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 遇到的坑:
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档