iOS自动化实践——WebDriverAgent(七)
WebDriverAgent使用过程中,发现Wifi可能会存在连接不稳定的情况,这个时候可以借助usb进行连接通信,怎么做呢?
实现方式
1、借助libusbmuxd
下载地址:https://github.com/libimobiledevice/libusbmuxd
2、libusbmuxd实现原理
pc端出去的http数据,走USB协议,然后USB回传回来后,映射成本地端口,走localhost 来进行本地HTTP协议,不用走wifi这种网络路由转发。Webdriveragent使用server端和client端通信,正好可以借助libusbmuxd。
3、使用方发:
(1)clone到本地:git clone https://github.com/libimobiledevice/libusbmuxd.git
(2)下载依赖:
需要注意的是libusbmuxd项目README中make和autoheader没有安装成功。
(3)编译安装:
(4)运行:iproxy LOCAL_TCP_PORT DEVICE_TCP_PORT [UDID]
,这里的LOCAL_TCP_PORT填写5000,因为Webdriveragent源码中写的local本地port是5000,DEVICE_TCP_PORT这里写的是8100,因为启动server以后监听的端口号是8100。
(5)启动iproxy以后,正常启动Webdriveragent server,然后在client端用例中传入的ip:port是localhost:5000
即可。
遇到的问题
1、出现libusbmuxd项目README中make和autoheader没有安装成功。
最后方案:未解决跳过。
2、出现./autogen.sh执行错误。
最后方案:执行./autogen.sh前,先执行下面的两条命令,然后编译通过。