mac webdriver java_[个人笔记] MAC 下安装WebDriverAgent

本文详细记录了在MAC上安装并配置WebDriverAgent的过程,包括git clone WebDriverAgent源码,运行初始化脚本,解决报错问题如修改bundle identifier,安装依赖,设备管理设置,端口转发以及测试运行中的日志信息。最后提到了用于微信跳一跳AI程序的额外组件安装。
摘要由CSDN通过智能技术生成

参考:https://testerhome.com/topics/7220

下载WebDriverAgent源码:

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

运行初始化脚本:

./Scripts/bootstrap.sh

该脚本会使用Carthage下载所有的依赖,使用npm打包相应的js文件。

执行这个脚本期间,会因为有些包没有安装而中断:

brew install carthage

brew install npm

WebDriverAgentRunner:

报错1:

The app ID "com.facebook.WebDriverAgentRunner" cannot be registered to your development team. Change your bundle identifier to a unique string to try again.

报这个错是因为WebDriverAgentRunner -> Build Settings -> Build Settings -> Packaging -> Product Bundle Identifier 要改成唯一可识别字符串

报错2:

"Failed to create provisioning profile.There are no devices registered in your account on the developer website. Plug in and select a device to have Xcode register it."

No profiles for 'com.rockets.provenance' were found Xcode couldn't find any iOS App Development provisioning profiles matching 'com.rockets.provenance'.

报这个错是因为没有接入相关的设备到MAC上,只要设备接入,并通过XCode菜单:Product->Destnation->"Select Devices"选中要连接的设备就行。

XCode:

Product->Destination->”Select your iphone”

Product->Scheme->”Select WebDriverAgentRunner”

Product -> Test

注意:运行Test之前,手机先解锁再通过USB线连接到电脑。

运行完”Test”,如果遇到这个报错:

error: failed to launch '/private/var/containers/Bundle/Application/BA42CC5E-D4BF-486F-A45D-4D172E0AFFA2/WebDriverAgentRunner-Runner.app' -- Verify the Developer App certificate for your account is trusted on your device. Open Settings on "iPhone name" and navigate to General -> Device Management, then select your Developer App certificate to trust it.

则需要在手机的通用->设备管理中,选择信任开发者证书。

测试运行期间,会在iphone的桌面上生成一个”WebDriverAgentRunner-Runner”的图标,生成类似下面格式的日志信息:

2018-03-12 15:28:44.099884+0800 WebDriverAgentRunner-Runner[1097:323808] +[CATransaction synchronize] called within transaction

2018-03-12 15:28:44.160403+0800 WebDriverAgentRunner-Runner[1097:323808] Running tests...

2018-03-12 15:28:46.791644+0800 WebDriverAgentRunner-Runner[1097:323808] Continuing to run tests in the background with task ID 1

2018-03-12 15:29:17.746896+0800 WebDriverAgentRunner-Runner[1097:323808] Continuing to run tests in the background with task ID 4

Test Suite 'All tests' started at 2018-03-12 15:29:18.420

Test Suite 'WebDriverAgentRunner.xctest' started at 2018-03-12 15:29:18.421

Test Suite 'UITestingUITests' started at 2018-03-12 15:29:18.422

Test Case '-[UITestingUITests testRunner]' started.

t = 0.00s Start Test at 2018-03-12 15:29:18.423

t = 0.00s Set Up

2018-03-12 15:29:18.440098+0800 WebDriverAgentRunner-Runner[1097:323808] Built at Mar 1 2018 18:50:16

2018-03-12 15:29:18.465613+0800 WebDriverAgentRunner-Runner[1097:323808] ServerURLHere->http://169.254.209.183:8100

这里,浏览器直接访问:http://169.254.209.183:8100 会一直超时,无法成功访问。解决方案如下:

端口转发:

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

配置方法:

brew install libimobiledevice

brew install ideviceinstaller

$ iproxy 8100 8100

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

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

运行微信跳一跳AI程序的话,还要安装如下组件:

pip install opencv-python

pip install facebook-wda

libimobiledevice又称libiphone,是一个开源包,可以让Linux支持连接iPhone/iPod Touch等iOS设备。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值