WebDriverAgent 安装备忘

A WebDriver server for iOS that runs inside the Simulator.

Andriod 有个类似的工具叫做 adb

开始

首先,将 WDA clone 下来,没有安装过 npm(不多说) 和 Carthage 的自行安装好。

git clone [email protected]:facebook/WebDriverAgent.git
brew install carthage

然后进入 clone 的 WDA 的目录,安装依赖:

./Scripts/bootstrap.sh

It will:

  • fetch all dependencies with Carthage
  • build Inspector bundle using npm

然后双击打开(默认已经安装 xcode)项目中的 WebDriverAgent.xcodeproj 文件。安装到真机上都是需要证书签名的,这里参考 此文

将第 5 处修改为任意随机字符串。

将 iPhone 与电脑连接。

菜单栏选择目标设备:

Scheme 选择 WebDriverAgentRunner:

最后运行 Product -> Test。

一切正常的话,手机上会出现一个无图标的 WebDriverAgent 应用,启动之后,马上又返回到桌面。这是很正常的不要奇怪。此时控制台界面可以看到设备的IP。如果看不到的话,使用这种方法打开:

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

端口转发

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

brew install libimobiledevice
iproxy 8100 8100

这时通过访问 http://localhost:8100/status 确认 WDA 是否运行成功。

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

其他问题

Product -> Test 运行时如果报错(Development cannot be enabled while your device is locked.),可以点击 设置 --> 通用 --> 重置 --> 重置位置和隐私,然后重新连接 usb,重启 xcode

猜你喜欢

转载自www.cnblogs.com/zichi/p/8944397.html
今日推荐