新手区 使用 findElementByXPath 查找元素,若 xpath 语法错误会导致 appium 服务直接挂掉

小灰 · 2016年08月02日 · 最后由 小灰 回复于 2016年08月03日 · 1659 次阅读

使用定时任务连续不间断的跑 400+ 个用例,执行 100 多个用例之后 appium 报错 error: uncaughtException: undefined is not a function,服务挂掉,起初以为是跑太久了它累了,然而并不是如此,多次尝试执行任务,发现每次执行 100 多个用例之后都会报错,并且服务挂掉,每次都是同样的错误,而且每次都是同一个用例报的错,让现场实施人员排查查找元素的方式,发现 xpath 写错了 [ps:都是复制粘贴惹得祸].

//android.widget.TextView[@text=\"收藏\"]/following-sibling::*[1](正确)
//android.widget.TextView[@text=\"收藏\"]/following::*[1]-sibling(错误)

意外的是 appium 对这个问题居然不是报错,而是直接崩了.....

错误日志如下:

error: uncaughtException: undefined is not a function date=Mon Aug 01 2016 21:16:13 GMT+0800 (CST), pid=69017, uid=501, gid=20, cwd=/Applications/Appium.app/Contents/Resources/node_modules/appium, execPath=/Applications/Appium.app/Contents/Resources/node/bin/node, version=v0.12.7, argv=[/Applications/Appium.app/Contents/Resources/node/bin/node, /Applications/Appium.app/Contents/Resources/node_modules/appium/lib/server/main.js, --command-timeout, 7200, --debug-log-spacing, --platform-version, 9.3, --platform-name, iOS, --app, /Users/shmobile/Desktop/CMBH_Client_V2.app, --no-reset, --show-ios-log, --device-name, iPhone 6 Plus, --native-instruments-lib], rss=317861888, heapTotal=285564160, heapUsed=108261992, loadavg=[3.3671875, 2.7548828125, 2.58935546875], uptime=3928219, trace=[column=46, file=/Applications/Appium.app/Contents/Resources/node_modules/appium/lib/devices/ios/ios-controller.js, function=, line=199, method=null, native=false, column=7, file=/Applications/Appium.app/Contents/Resources/node_modules/appium/lib/devices/ios/ios-controller.js, function=Object.cb [as callback], line=261, method=cb [as callback], native=false, column=43, file=/Applications/Appium.app/Contents/Resources/node_modules/appium/node_modules/async/lib/async.js, function=next, line=798, method=null, native=false, column=16, file=/Applications/Appium.app/Contents/Resources/node_modules/appium/node_modules/async/lib/async.js, function=null, line=32, method=null, native=false, column=9, file=/Applications/Appium.app/Contents/Resources/node_modules/appium/lib/devices/common.js, function=[object Object].exports.respond, line=28, method=exports.respond, native=false, column=18, file=/Applications/Appium.app/Contents/Resources/node_modules/appium/lib/devices/ios/ios.js, function=, line=1498, method=null, native=false, column=20, file=/Applications/Appium.app/Contents/Resources/node_modules/appium/submodules/appium-uiauto/lib/command-proxy.js, function=getResultAndSendNext, line=146, method=null, native=false, column=7, file=/Applications/Appium.app/Contents/Resources/node_modules/appium/submodules/appium-uiauto/lib/command-proxy.js, function=, line=88, method=null, native=false, column=20, file=events.js, function=Socket.emit, line=129, method=emit, native=false, column=16, file=_stream_readable.js, function=null, line=908, method=null, native=false, column=11, file=node.js, function=process._tickDomainCallback, line=381, method=_tickDomainCallback, native=false], stack=[TypeError: undefined is not a function, at [object Object]. (/Applications/Appium.app/Contents/Resources/node_modules/appium/lib/devices/ios/ios-controller.js:199:46), at Object.cb as callback, at next (/Applications/Appium.app/Contents/Resources/node_modules/appium/node_modules/async/lib/async.js:798:43), at /Applications/Appium.app/Contents/Resources/node_modules/appium/node_modules/async/lib/async.js:32:16, at [object Object].exports.respond (/Applications/Appium.app/Contents/Resources/node_modules/appium/lib/devices/common.js:28:9), at [object Object]. (/Applications/Appium.app/Contents/Resources/node_modules/appium/lib/devices/ios/ios.js:1498:18), at getResultAndSendNext (/Applications/Appium.app/Contents/Resources/node_modules/appium/submodules/appium-uiauto/lib/command-proxy.js:146:20), at Socket. (/Applications/Appium.app/Contents/Resources/node_modules/appium/submodules/appium-uiauto/lib/command-proxy.js:88:7), at Socket.emit (events.js:129:20), at _stream_readable.js:908:16, at process._tickDomainCallback (node.js:381:11)]

共收到 2 条回复 时间 点赞
Monkey 内容不符合版规屏蔽此话题 08月02日 17:24

新人请阅读:https://testerhome.com/topics/982
学会如何合理提问,请阅读:https://testerhome.com/topics/587

#2 楼 @monkey 改了,这样可以么

需要 登录 后方可回复, 如果你还没有账号请点击这里 注册