• 欢迎访问开心洋葱网站,在线教程,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站,欢迎加入开心洋葱 QQ群
  • 为方便开心洋葱网用户,开心洋葱官网已经开启复制功能!
  • 欢迎访问开心洋葱网站,手机也能访问哦~欢迎加入开心洋葱多维思维学习平台 QQ群
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏开心洋葱吧~~~~~~~~~~~~~!
  • 由于近期流量激增,小站的ECS没能经的起亲们的访问,本站依然没有盈利,如果各位看如果觉着文字不错,还请看官给小站打个赏~~~~~~~~~~~~~!

Xcode9 IOS 真机如何安装 WebDriverAgent自动化测试

其他 开心洋葱 2472次浏览 1个评论

Xcode9 IOS 真机如何安装 WebDriverAgent自动化测试

WDA在Github的首页上有一个很简单的安装说明 https://github.com/facebook/WebDriverAgent,参考这个,我再增加一些配图,以及自己使用过程中的一些体会。

开始

尽量升级Xcode到最新版,保持iPhone的版本大于9.3

从github上下载代码

git clone https://github.com/facebook/WebDriverAgent
运行初始化脚本

./Scripts/bootstrap.sh

没有安装可以安装
brew install carthage或github下载

执行完成后,直接双击打开WebDriverAgent.xcodeproj这个文件或执行(记得把包名、证书都更换为自己的)

UDID=$(idevice_id -l | head -n1)

xcodebuild -project WebDriverAgent.xcodeproj -scheme WebDriverAgentRunner -destination “id=$UDID” test

执行成功后,通过DEBUG输出给出的IP和端口,加上/status合成一个url地址。例如http://10.0.0.1:8100/status,然后浏览器打开。如果出现一串JSON输出,说明WDA安装成功了。

端口转发

有些国产的iPhone机器通过手机的IP和端口还不能访问,此时需要将手机的端口转发到Mac上。

$ brew install imobiledevice
$ iproxy 8100 8100
使用iproxy –help 可以查到更具体的用法。 这时通过访问http://localhost:8100/status确认WDA是否运行成功。

而inspector的地址是http://localhost:8100/inspector, inspector是用来查看UI的图层,方便写测试脚本用的

自动脚本:

# 解锁keychain,以便可以正常的签名应用,
PASSWORD="replace-with-your-password"
security unlock-keychain -p $PASSWORD ~/Library/Keychains/login.keychain

# 获取设备的UDID
UDID=$(idevice_id -l | head -n1)

# 运行测试
xcodebuild -project WebDriverAgent.xcodeproj -scheme WebDriverAgentRunner -destination "id=$UDID" test

遇到的错误:

错误1:
dst_ipa: /var/folders/zp/8jcfxwwn0b38w_r237yjt5300000gn/C/com.apple.DeveloperTools/All/Xcode/EmbeddedAppDeltas/WebDriverAgentRunner-Runner.app.IFu6A9/WebDriverAgentRunner-Runner.app_sparse.ipa
MDMDirectoryDiff_block_invoke:1473 calling writeDictToFile with: /var/folders/zp/8jcfxwwn0b38w_r237yjt5300000gn/C/com.apple.DeveloperTools/All/Xcode/EmbeddedAppDeltas/WebDriverAgentRunner-Runner.app.IFu6A9/WebDriverAgentRunner-Runner.app_sparse.ipa/ManifestCache.plist
writeDictToFile:1278 ==== Successfully wrote Manifest cache to /var/folders/zp/8jcfxwwn0b38w_r237yjt5300000gn/C/com.apple.DeveloperTools/All/Xcode/EmbeddedAppDeltas/WebDriverAgentRunner-Runner.app.IFu6A9/WebDriverAgentRunner-Runner.app_sparse.ipa/ManifestCache.plist
2018-01-07 00:00:36.656 xcodebuild[528:4837] Error Domain=IDETestOperationsObserverErrorDomain Code=6 “Early unexpected exit, operation never finished bootstrapping – no restart will be attempted” UserInfo={NSLocalizedDescription=Early unexpected exit, operation never finished bootstrapping – no restart will be attempted}

Testing failed:
Early unexpected exit, operation never finished bootstrapping – no restart will be attempted
** TEST FAILED **
错误2:
WebDriverAgentRunner): no suitable image found. Did find:
/var/containers/Bundle/Application/2AD41242-A9B6-41F9-BE8F-A8ECBEB5D9B4/WebDriverAgentRunner-Runner.app/PlugIns/WebDriverAgentRunner.xctest/WebDriverAgentRunner: unknown file type, first eight bytes: 0x21 0x3C 0x61 0x72 0x63 0x68 0x3E 0x0A)
错误3:
Connection peer refused channel request for “dtxproxy:XCTestDriverInterface:XCTestManager_IDEInterface”; channel canceled
解决:
1/sudo xcode-select –switch /Applications/Xcode.app/Contents/Developer/

注意:本段内容须成功“回复本文”后“刷新本页”方可查看!

参考文献:
ATX 文档 – iOS 真机如何安装 WebDriverAgent https://testerhome.com/topics/7220
http://blog.163.com/l1_jun/blog/static/143863882017741031596/
iOS 测试 WebDriverAgent 天坑记 https://testerhome.com/topics/9666
Macaca2.0 升级公告 https://testerhome.com/topics/8687
iOS-remote 安装篇之 WebDriverAgent 安装使用完全指南 https://testerhome.com/topics/10463


开心洋葱 , 版权所有丨如未注明 , 均为原创丨未经授权请勿修改 , 转载请注明Xcode9 IOS 真机如何安装 WebDriverAgent自动化测试
喜欢 (1)

您必须 登录 才能发表评论!

(1)个小伙伴在吐槽
  1. 有点恶心吧,每次让回复
    李永康2018-09-04 00:05
加载中……