automatorx搭建ios自动化测试环境

    xiaoxiao2021-11-30  20

    automatorx简介:

    由网易游戏部门开源的项目,ios端现在由Webdriveragent驱动,android端由Automator驱动。

    完全的黑盒测试框架,无需知道项目代码,非侵入式支持iOS, Android的自动化测试,两个平台都支持测试第三方应用对于iOS的真机,安卓模拟器都能很好的支持可以用来测试Windows应用对于游戏的测试使用了图像识别同一个测试脚本可以通过图像的缩放算法,适配到其他分辨率的手机上 支持环境: 只支持Python2的测试脚本Android 4.1+iOS 9.0+iOS测试必须要有一个Mac 安装部署步骤:

    1、安装carthage,使用前最好brew update下

    brew install carthage

    2、WebDriverAgent下载

    git clone https://github.com/facebook/WebDriverAgent.git

    3、终端进入下载的目录,执行以下命令安装

    cd /Users/sarah/Downloads/WebDriverAgent-master

    ./Scripts/bootstrap.sh

    4、在Finder里进入目录/Users/sarah/Downloads/WebDriverAgent-master双击打开WebDriverAgent.xcodeproj

    5、Xcode中添加AppleID Xcode--Prefencens--Accounts

    6、创建iOS Development Singing Identities Accounts--View Details--iOS Development—Create

    7、给webdriveragentrunner和WebDriverAgentLib重签名

    修改webdriveragentrunner Product Bundle Identifier

    8、安装libimobiledevice,解决ios10不能通过wifi通信,使用iproxy代理实现usb通信。

     Making iproxy run automatically in the background on OS X Install it with Homebrew (brew install libimobiledevice) Create the file ~/Library/LaunchAgents/com.usbmux.iproxy.plist with the contents: <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>Label</key> <string>com.usbmux.iproxy</string> <key>ProgramArguments</key> <array> <string>/usr/local/bin/iproxy</string> <string>8100</string> <string>8100</string> </array> <key>RunAtLoad</key> <true/> <key>KeepAlive</key> <true/> </dict> </plist> run launchctl load ~/Library/LaunchAgents/com.usbmux.iproxy.plist You now don't have to run the iproxy binary every time you want to SSH over USB as the iproxy software is always running in the background.

    9、启动xcode编译WebDriverAgentRunner进行测试,成功跑起来之后,会发现iOS上多了一个名叫WebDriverAgent的App, App实际上启动了一个服务器,监听的端口是8100 模拟器的ip是127.0.0.1, 所以其DEVICE_URL就是http://127.0.0.1:8100, 真机的需要查看手机Wifi的IP地址。

    或者在终端上当前目录输入以下命令启动编译测试

    xcodebuild -project WebDriverAgent.xcodeproj -scheme WebDriverAgentRunner -destination "id=$(idevice_id -l)" test

    命令行下成功编译运行截图:

    10、WDA运行完之后,准备好DEVICE_URL, 如 http://localhost:8100 如果是真机,需要将localhost改成手机的IP地址(ios10的iPhone通过命令“iproxy 8100 8100”把地址映射本地后,然后用http://localhost:8100访问) python代码可以这样写

    # coding: utf-8 import atx d = atx.connect('http://localhost:8100', platform='ios') # platform也可以不指定 print d.status()

    11、随后打开127.0.0.1:8100/inspector 这个地址,就可以看到一个酷炫的界面(我来截个图)

    左边屏幕图像,右边具体的元素信息,所有这些东西都是我们写脚本的时候需要用到的。

    12、截图

    python -m atx gui --serialhttp://localhost:8100

    13、简单实例:

    import atx d = atx.connect("http://localhost:8100") d.start_app("com.apple.mobiletimer") d(text=u'计时器').click() d(text=u'开始计时').click() d(text=u'取消').click() d.stop_app()

    转载请注明原文地址: https://ju.6miu.com/read-678959.html

    最新回复(0)