Appium Appium1.6.3+iOS 10.2 一直 Waiting for WebDriverAgent server to finish loading...

zuiniao123 · December 18, 2016 · Last by Kevin Tu replied at September 19, 2019 · 3600 hits

同样的配置在Appium1.6.3+iOS 9.3就能跑起来,在Appium1.6.3+iOS 10.2上(已经添加了'XCUITest')就一直处于Waiting for WebDriverAgent server to finish loading...不动了

操作步骤:

1.wda签名并且用xcodebuild命令装在手机上

2.命令行启动appium

3.log 一直显示Waiting for WebDriverAgent server to finish loading...不动了

有没有大神经历过的,求解救😳

Last login: Sun Dec 18 19:35:39 on ttys000
suqingdeMacBook-Pro:~ xcc$ appium
[Appium] Welcome to Appium v1.6.3
[Appium] Appium REST http interface listener started on 0.0.0.0:4723
[HTTP] --> POST /wd/hub/session {"desiredCapabilities":{"app":"/Users/xcc/Desktop/应用名称.ipa","platformVersion":"10.2","bundleId":"com.应用名称.应用名称","automationName":"XCUITest","platformName":"iOS","udid":"7e7b54c63xxxxxxxxxxxx1aeb3dcf0ace1e7","deviceName":"iPhone 6"}}
[debug] [MJSONWP] Calling AppiumDriver.createSession() with args: [{"app":"/Users/xcc/Desktop/应用名称.ipa","platformVersion":"10.2","bundleId":"com.应用名称.应用名称","automationName":"XCUITest","platformName":"iOS","udid":"7e7b54c63xxxxxxxxxxxx1aeb3dcf0ace1e7","deviceName":"iPhone 6"},null,null,null,null]
[Appium] Creating new XCUITestDriver session
[Appium] Capabilities:
[Appium] app: '/Users/xcc/Desktop/应用名称.ipa'
[Appium] platformVersion: '10.2'
[Appium] bundleId: 'com.应用名称.应用名称'
[Appium] automationName: 'XCUITest'
[Appium] platformName: 'iOS'
[Appium] udid: '7e7b54c63xxxxxxxxxxxx1aeb3dcf0ace1e7'
[Appium] deviceName: 'iPhone 6'
[debug] [XCUITest] XCUITestDriver version: 2.4.3
[BaseDriver] Session created with session id: a819d5cf-17f8-4143-9d98-4180c49c5fa9
[debug] [XCUITest] Xcode version set to '8.2'
[debug] [XCUITest] iOS SDK Version set to '10.2'
[debug] [XCUITest] Available devices: 7e7b54c63xxxxxxxxxxxx1aeb3dcf0ace1e7, c4b16cefccccccccccccb43a9b88819
[debug] [XCUITest] Creating iDevice object with udid 7e7b54c63xxxxxxxxxxxx1aeb3dcf0ace1e7
[XCUITest] Determining device to run tests on: udid: '7e7b54c63xxxxxxxxxxxx1aeb3dcf0ace1e7', real device: true
[BaseDriver] Using local app '/Users/xcc/Desktop/应用名称.ipa'
[debug] [BaseDriver] Copying local zip to tmp dir
[debug] [BaseDriver] Unzipping /var/folders/vn/c4srrmj53f367lw984kxs1100000gn/T/20161118-2308-5ymsl3.lobf0f6r/appium-app.zip
[debug] [BaseDriver] Testing zip archive: /var/folders/vn/c4srrmj53f367lw984kxs1100000gn/T/20161118-2308-5ymsl3.lobf0f6r/appium-app.zip
[BaseDriver] Unzipped local app to '/var/folders/vn/c4srrmj53f367lw984kxs1100000gn/T/20161118-2308-5ymsl3.lobf0f6r/Payload/应用名称.app'
[debug] [XCUITest] Checking whether app '/var/folders/vn/c4srrmj53f367lw984kxs1100000gn/T/20161118-2308-5ymsl3.lobf0f6r/Payload/应用名称.app' is actually present
[debug] [XCUITest] App is present
[debug] [iOSLog] Attempting iOS device log capture via libimobiledevice idevicesyslog
[debug] [iOSLog] Found idevicesyslog: '/usr/local/bin/idevicesyslog'
[XCUITest] Setting up real device
[debug] [XCUITest] App is already installed.
[debug] [XCUITest] Full reset not requested. No need to install.
[XCUITest] Using WDA path: '/usr/local/lib/node_modules/appium/node_modules/.2.4.3@appium-xcuitest-driver/WebDriverAgent'
[XCUITest] Using WDA agent: '/usr/local/lib/node_modules/appium/node_modules/.2.4.3@appium-xcuitest-driver/WebDriverAgent/WebDriverAgent.xcodeproj'
[XCUITest] Launching WebDriverAgent on the device
[debug] [XCUITest] Carthage found: /usr/local/bin/carthage
[debug] [XCUITest] Killing hanging processes
[debug] [XCUITest] Using real device logger 'idevicesyslog'
[debug] [XCUITest] Beginning test with command 'xcodebuild build test -project /usr/local/lib/node_modules/appium/node_modules/.2.4.3@appium-xcuitest-driver/WebDriverAgent/WebDriverAgent.xcodeproj -scheme WebDriverAgentRunner -destination id=7e7b54c632bcaa44f661726271aeb3dcf0ace1e7 -configuration Debug' in directory '/usr/local/lib/node_modules/appium/node_modules/.2.4.3@appium-xcuitest-driver/WebDriverAgent'
[XCUITest] Waiting for WebDriverAgent to start on device
[debug] [XCUITest] Log file for xcodebuild test: /Users/xcc/Library/Developer/Xcode/DerivedData/WebDriverAgent-cdbymtonqyssjhfwnanxtomfuiox/Logs/Test/E7B7B6B5-8059-4318-AD61-94CBF29F586F/Session-WebDriverAgentRunner-2016-12-18_193752-eXQWNA.log
[debug] [WebDriverAgent] Device: Dec 18 19:37:59 iPhone XCTRunner[472] <Notice>: Running tests...
[debug] [WebDriverAgent] Device: Dec 18 19:38:01 iPhone XCTRunner[472] <Notice>: Continuing to run tests in the background with task ID 1
[debug] [XCUITest] Waiting for WebDriverAgent server to finish loading...
[debug] [XCUITest] Waiting for WebDriverAgent server to finish loading...
[debug] [XCUITest] Waiting for WebDriverAgent server to finish loading...
[debug] [XCUITest] Waiting for WebDriverAgent server to finish loading...
[debug] [XCUITest] Waiting for WebDriverAgent server to finish loading...
共收到 29 条回复 时间 点赞

@楼主,请问你解决了吗?我也遇到这个一模一样的问题,研究了2天还没有解决,环境是appium1.6.3+xcode8.2+ios10.2iphone6P真机。

#1楼 @meil000 搞不定啊 只能等等其他大神了

#2楼 @zuiniao123 我发现应该是WebDriverAgent的BUG(Appium就是调用WebDriverAgent实现XUITest真机自动化),我用IOS9.3和IOS10.2两部手机做了试验,用Terminal进入到WebDriverAgent工程目录下,连接手机后运行命令"xcodebuild -project WebDriverAgent.xcodeproj -scheme WebDriverAgentRunner -destination 'id=你的UDID' test",可以看到区别:

1:IOS9.3手机的运行结果明确提示:Listening on USB

2:IOS10.2手机的运行结果没有上面的提示,而是一直卡在下面这段:
Test Case '-[UITestingUITests testRunner]' started.
t = 0.00s Start Test at 2016-12-20 09:58:02:209
t = 0.01s Set Up

我去github的WebDriverAgent下载安装了最新的版本,测试后一样有这个问题,我猜测WebDriverAgent目前不支持IOS10最近几个新版本的真机运行。

#3楼 @meil000 。。。我后来又试了,在ios10.2上也有Listening on USB的提示的

#4楼 @zuiniao123 不好意思之前写错命令,是执行这个命令“xcodebuild -project WebDriverAgent.xcodeproj -scheme WebDriverAgentRunner -destination 'id=你的UDID' test”,你是在xcode里面运行test后看到提示Listening on USB,还是在Terminal运行上面命令后看到提示Listening on USB? 我的iphone6P是国行的,不知道和手机型号有没有关系。。

appium1.6.3支持IOS真机测试吗?

我也遇到同样的问题啊,烦恼啊

The problem solved by installing xcuitest-driver VERSION v2.0.36 (downgraded from v2.4.2)

cd /usr/local/lib/node_modules/appium
npm uninstall appium-xcuitest-driver
npm install appium-xcuitest-driver@2.0.36

@shljsh 按你的方法,APP拉不起来

#9楼 @miaomiao413 我自己试过是好用的 2.4.2的版本我也拉不起来 降级到2.0.36就没问题

现在xcuitest有2.5.0的版本了 试了下已经可以把真机的app拉起来了

我的解决方案(仅供参考):

appium-xcuitest-driver@2.4.0中的/lib/webdriveragent.jswaitForStart函数中,需要获得WDA的启动时间与系统时间做对比,导致reachedEnd一直是false,测试进程卡住,等待WDA启动,具体的代码如下:

async waitForStart (startTime) {
// we have to wait for the sim to start before we can tail the log file
if (!this.realDevice) {
await systemLogExists(this.device);
}

let agentUrl;
let lineCount = 0;
let reachedEnd = !this.realDevice; // simulator does not need to wait, since we are tailing
let showWaitingMessage = true; // turn off logging once we have hit the end

let startDetector = (stdout) => {
// on a real device there may already be system logs that need to be
// passed before we get to the real startup logs, otherwise
// we expect two lines, one after another
// Jul 20 13:03:57 iamPhone XCTRunner[296] <Warning>: Built at Jul 20 2016 13:03:50
// Jul 20 13:03:57 iamPhone XCTRunner[296] <Warning>: ServerURLHere->http://10.35.4.122:8100<-ServerURLHere
if (!reachedEnd) {
let dateMatch = REAL_DEVICE_BUILD_LOG_STARTTIME_REGEX.exec(stdout);
if (dateMatch) {
let buildTime = new Date(dateMatch[1]);
if (buildTime.isAfter(startTime)) {
reachedEnd = true;
}
}
}

if (reachedEnd) {
let match = AGENT_STARTED_REGEX.exec(stdout);
if (match) {
agentUrl = match[1];
log.info(`Detected that WebDriverAgent is running at url '${agentUrl}'`);
if (!agentUrl) {
log.errorAndThrow(new Error('No url detected from WebDriverAgent'));
}
showWaitingMessage = false;
return true;
}
}

// periodically log, so it does not look like everything died
lineCount++;
let threshold = this.realDevice ? 5000 : 200;
if (showWaitingMessage && lineCount % threshold === 0) {
log.debug('Waiting for WebDriverAgent server to finish loading...');
}

return false;
};

log.info('Waiting for WebDriverAgent to start on device');
await this.deviceLogs.start(startDetector);
log.info(`WebDriverAgent started at url '${agentUrl}'`);

return agentUrl;
}

解决方法:

当前的解决方案是修改对应代码:

if (!reachedEnd) {
// let dateMatch = REAL_DEVICE_BUILD_LOG_STARTTIME_REGEX.exec(stdout);
// if (dateMatch) {
// let buildTime = new Date(dateMatch[1]);
// if (buildTime.isAfter(startTime)) {
// reachedEnd = true;
// }
// }
reachedEnd = true;
log.info("ReachedEnd is set true!")
}

PS:
appium-xcuitest-driver@2.4.3与2.4.0的源码不一样,但是原理差不多。
另外,需要修改build中编译后的文件或者修改后编译一下。

我也是遇到同样问题,有没有大神解决。另外我导出的debug版的ipa包装到模拟器上,一打开就闪退,不知道啥原因

Appium1.6.3, iOS10.1.1,楼上的各种方法都试过了,也还是一样的错误,没有listen on USB出来。 @shljsh 请问还有其他解决方法吗? 降级、升级、改12楼的代码 这些都试过了还是不行。

一个月前遇到这个问题,也看到这个帖子可惜没有解决方法。。后来自己折腾了几天解决了,说一下我的解决方法吧,虽然不一定每个人的问题都相同,至少可以尝试一下:
appium到目前为止,使用的FB提供的webdriveragent驱动一直存在一个bug,不支持中国国行全系iphone的wifi连接,FB也没有打算修复此bug,如果大家用appium测试中国国行iphone,webdriveragent就可能一直卡死,解决方法是使用iproxy将wifi的tcp协议转换成usb协议,具体方法:
1)安装并启动iproxy把webdriveragent的默认8100端口转到usb协议(安装需联网):
$ brew uninstall ideviceinstaller
$ brew uninstall libimobiledevice
$ brew install --HEAD libimobiledevice
$ brew install ideviceinstaller
$ iproxy 8100 8100
注意webdriveragent监听的默认端口是8100,如果你修改过端口,这里就改成你定义的端口
2)手动启动webdriveragent:
xcodebuild -project /usr/local/lib/node_modules/appium/node_modules/appium-xcuitest-driver/WebDriverAgent/WebDriverAgent.xcodeproj -scheme WebDriverAgentRunner -destination ‘id= 你的设备UDID’ test
3)确认webdriveragent在iphone上安装并启动后,就可以启动appium了,重要的是在启动appium的cap中传入下面这个参数,让appium连接上面步骤中手动启动的WebDriverAgent:

webDriverAgentUrl
http://localhost:8100

上面是关键!要传入这个cap,不要让appium自己启动WebDriverAgent,因为前面说了,appium自己启动WebDriverAgent会引发bug,导致中国国行手机无法与WebDriverAgent通过tcp协议通信,然后一直卡死。
4)执行测试用例,看看这次是不是不会卡着了。。。

17Floor has been deleted

@楼主 请问解决了吗
该怎么解决这个问题 各位大神

#16楼 @meil000 这个方法挺赞的。解决了一个手机卡在wda启动时的问题

meil000 回复

你好 请问Listening on USB 没有的那个问题解决了吗?10.2的真机我这边也没有显示,但是虚拟机10.2的却有。

steven iOS 真机运行 Appium 长期答疑! 中提及了此贴 04 Mar 22:25

@meil000 @zuiniao123 我也遇到这个问题了,你们清楚是什么引起的了嘛? 同一台手机,在公司电脑安装好的环境可以了,回到家里mbp安装环境后出现这个问题

meil000 回复

Appium还是超时。直接localhost直接curl那个接口很不稳定,经常没有返回。iproxy的日志:
recv failed: Resource temporarily unavailable
recv failed: Resource temporarily unavailable
recv failed: Resource temporarily unavailable
recv failed: Resource temporarily unavailable
recv failed: Resource temporarily unavailable

国行真机真的有点儿扯。
稍后试试WDA自己的USB链接方式看看行不行。

meil000 回复

大神 请问一下,这个问题只存在于国行手机吗,如果我换了非国行的手机,是不是就不会一直waiting了

我昨天也遇到這樣的問題後來我找了一個方法
cd /usr/local/lib/node_modules/appium
npm uninstall appium-xcuitest-driver
npm install appium-xcuitest-driver@2.5.3
就可以嚕~ 可以試試看

xcode8.2没有ios 10.2的sdk吧,xcode里看一下。记得应该是xcode8.2.1集成了ios10.2的sdk

陈琪 回复

这个Listening on USB的日志提示,我后来发现似乎不同版本iphone有的会打印,有的不打印,但不影响实际测试。
比如目前我的iphone6P启动WDA后,并不提示Listening on USB,但appium运行自动化一切正常,所以个人觉得可以忽略了。

promise 回复

是的,这个国行iphone的问题,之前在facebook的github上已经有人确认了,只有国行有问题,你换港行就没有问题。
最近Facebook有没有解决这个bug我还不清楚。我一直用iproxy映射USB连接规避这个问题的。

meil000 回复

您好,我的是IOS10.2手机
(1)使用命令“xcodebuild -project WebDriverAgent.xcodeproj -scheme WebDriverAgentRunner -destination 'id=你的UDID' test”一直卡在Set Up:
Test Case '-[UITestingUITests testRunner]' started.
t = 0.00s Start Test at 2016-12-20 09:58:02:209
t = 0.01s Set Up
(2)命令“iproxy 8100 8100”输出:
recv failed: Resource temporarily unavailable
recv failed: Resource temporarily unavailable
recv failed: Resource temporarily unavailable
recv failed: Operation not permitted
(3)打开 “http://localhost:8100/status” 是好的,但是打开 “http://localhost:8100/inspector” 显示空白,请教下是怎么回事?
(4)打开手机上的WebDriverAgent App整个黑屏
请问大神有什么解决方法吗?看到前面的回复说可能是国行手机的问题,那现在这个问题有解决吗?

我手机上webdriverAgent启动了,用iproxy 8100 8100,后。 访问电脑http://xxxxx:8100/inspector,打不开,有知道为什么的吗?我搞不明白,希望知道的能解答下,谢谢

chen.zhou 回复

我手机上webdriverAgent启动了,用iproxy 8100 8100,后。 访问电脑http://xxxxx:8100/inspector,打不开,有知道为什么的吗?我搞不明白,希望知道的能解答下,谢谢
你解决了吗

chen.zhou 回复

你解决了吗?遇到同样的问题

需要 Sign In 后方可回复, 如果你还没有账号请点击这里 Sign Up