c4rt1y

appium真机调试app的问题-WebDriverAgent踩坑

0x01 介绍

解决在使用appium调用ios真机测试软件的时候,出现WebDriverAgent的bug修复。

0x02 问题及处理方法

情节描述,使用mac下的ios模拟器运行都是ok,但是使用真机运行,通过ios-deploy和idevice_id -l 等命令都能找到设备信息,主要报错信息为如下:

xcodebuild failed with code 65

command: Error: Unable to launch WebDriverAgent because of xcodebuild failure: "xcodebuild failed with code 65". Make sure you follow the tutorial athttps://github.com/appium/appium-xcuitest-driver/blob/master/docs/real-device-config.md. Try to remove the WebDriverAgentRunner application from the device if it is installed and reboot the device.

其实核心原因是新版本证书失效,需要对代码添加证书,同时重新编译。

在老版本中,存在这样的问题,不支持高版本的xcode,在11.4的时候修复了,https://github.com/appium/WebDriverAgent/pull/286/files。当前情况下,我们只需要在电脑上找到WebDriverAgentRunner工程的地址,然后加载证书编译,然后写到个人真机上,就可以实现真机调试

1、找到WebDriverAgentRunner项目
find / -name WebDriverAgentRunner

/usr/local/lib/node_modules/appium/node_modules/appium-webdriveragent/WebDriverAgentRunner
/usr/local/lib/node_modules/appium/node_modules/appium-mac2-driver/WebDriverAgent/WebDriverAgentRunner
/usr/local/lib/node_modules/appium/node_modules/appium-mac2-driver/WebDriverAgent/WebDriverAgent/WebDriverAgentRunner
/usr/local/lib/node_modules/appium/node_modules/appium-mac2-driver/WebDriverAgentMac_bak/WebDriverAgentRunner
/usr/local/lib/node_modules/appium/node_modules/appium-mac2-driver/WebDriverAgentMac/WebDriverAgentRunner
/usr/local/lib/node_modules/appium/node_modules/appium-mac2-driver/WebDriverAgentMac/WebDriverAgent/WebDriverAgentRunner

2、进入目录
cd /usr/local/lib/node_modules/appium/node_modules/appium-webdriveragent/WebDriverAgentRunner

双击打开WebDriverAgent.xcodeproj

3、使用,如下图所示(因为个人有开发者账号,如果是免费版,请看资料来源)

configure-xcode-with-webdriveragent

4、运行到个人手机上,选择Product -> Destination -> 你的连接的真机名,手机上会安装一个WebDriverAgent就可以了

5、当安装完毕
xcode会出现一个类似于:
ServerURLHERE->http://192.168.xxx.xxx:8100<-ServerURLHERE

手机端可以使用浏览器访问:
localhost:8100/status


后续为了方便操作,可以直接使用自动化操作,这样就可以不使用直接命令行操作
PASSWORD="个人电脑开机密码"
security unlock-keychain -p $PASSWORD ~/Library/Keychains/login.keychain
UDID=$(idevice_id -l | head -n1)
xcodebuild -project WebDriverAgent.xcodeproj -scheme WebDriverAgentRunner -destination "id=$UDID" test

0x03 资料来源

https://www.jianshu.com/p/568e1f4b152a
https://www.jianshu.com/p/5a70ea56abe4
https://blog.csdn.net/manypeng/article/details/106547750
https://blog.csdn.net/ypf1024/article/details/109892431
GoTop