目录
前言
朋友让我帮忙制作一个可以自动划手机的东西,手边只有Iphone于是研究了IOS自动化相关的东西。
步骤
初始环境
安装XCode
安装Brew
升级Pip
下载WebDriverAgent
首先从github上下载WebDriverAgent
链接:https://github.com/appium/WebDriverAgent/releases
下载完成后解压
打开WebDriverAgent工程
双击xcodeproj文件打开项目

项目配置
选择WebDriverAgentRunner项目打包到手机

设置开发者
进入Signing设置,选择一个Team,这个是可以免费申请的测试账号

下面这一步如果可以正常运行则不需要操作
进入Build Setting面板选择Basic和Combined找到Packaging下面的Product Bundle Identifier将中间的facebook修改成其他名字。

打包测试
点击Product下面的Test,手机会自动打开App然后回到桌面状态,并出现一个空白的app图标

找到WDA服务器地址
点击左下脚的console窗口,在console中找到
ServerURLHere->http://169.254.250.121:8100<-ServerURLHere
此处说明打开了wda服务器

安装libimobiledevice用于端口转发
国内镜像安装braw
/bin/bash -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)"安装完brew可能会出现以下提示,直接复制粘贴命令输入即可
You should change the ownership of these directories to your user. sudo chown -R $(whoami) /usr/local/share/zsh /usr/local/share/zsh/site-functions And make sure that your user has write permission. chmod u+w /usr/local/share/zsh /usr/local/share/zsh/site-functions
使用braw安装libimobiledevice
PS:需要加上 –HEAD 选项,如果不加,安装是老版本,不支持iOS10的手机,所以安装时,需要加上 –HEAD 选项
brew install libimobiledevice --HEAD

设置端口代理
安装完成后设置端口代理
iproxy 8100 8100

查看服务器状态
进入网页查看服务器状态,state为success即为成功

安装WEditor
安装weditor,用来连接wda服务器
pip install weditor

运行WEditor
运行weditor(此处要选择你自己高版本的python)
python3 -m weditor

配置WEditor
将自动弹出WEditor网页,在上方选择IOS,链接地址基本不需要修改,再点击Connect,当按钮后面出现小绿叶的时候表示连接成功,点击Dump Hierarchy即可显示当前手机画面,右侧可以使用Python语言进行自动化测试。

参考
***初识 iOS 自动化测试框架 WebDriverAgent https://www.cnblogs.com/zgq123456/p/9979280.html
详细记录 https://www.mutuallyhuman.com/blog/webdriveragent-getting-started-with-automated-ios-testing/
端口转发问题 https://testerhome.com/topics/7220
libimobiledevice常用命令 https://www.cnblogs.com/lilip/p/11402447.html
IOS真机测试 https://blog.csdn.net/weixin_26735419/article/details/108496875
1875

被折叠的 条评论
为什么被折叠?



