Appium LocationService Alert 问题

Vincent · 2014年04月25日 · 最后由 linda 回复于 2015年11月18日 · 1587 次阅读

我们 app 一启动就会申请定位服务权限,开始我直接用 Alert.accept() 处理,会报找不到 alert 控件(100% 报错),但实际上模拟器是已经处理了(30% 处理几率),后来在 github 上查资料发现可以设 useLocationServices: true 之后 appium 会自动 accept,但实际上也有较大几率会不处理,就卡在申请定位权限的弹窗上。。。

再后来发现有个贱人把 Appium auto-accepting or dismissing of alerts remove 掉了。。。。(https://github.com/appium/appium/pull/1299)我了个擦了,还能一起愉快的玩耍吗??!

对了我也发现 Jonathan 说类似的情况需要设延迟(https://github.com/appium/appium/issues/2013sleep),但我换了各姿势的延迟( wait )也没发现有效。。

有没有盆友知道怎么处理的,求分享

log

info: [INST] 2014-04-25 09:46:46 +0000 Fail: Could not start script, target application is not frontmost.

info: [INST] Instruments Trace Complete (Duration : 19.252544s; Output : /usr/local/lib/node_modules/appium/instrumentscli0.trace)

org.openqa.selenium.remote.UnreachableBrowserException:
Could not start a new session. Possible causes are invalid address of the remote server or browser start-up failure.

共收到 9 条回复 时间 点赞

把他原来的代码重新补上呗 概率的问题估计还是等待那块没处理好,

error: Failed to start an Appium session, err was: Error: Instruments crashed on startup
info: Error: Instruments crashed on startup
at Instruments.onInstrumentsExit (/usr/local/lib/node_modules/appium/node_modules/appium-instruments/lib/instruments.js:385:31)
at null. (/usr/local/lib/node_modules/appium/node_modules/appium-instruments/lib/instruments.js:328:12)
at ChildProcess.EventEmitter.emit (events.js:98:17)
at Process.ChildProcess._handle.onexit (child_process.js:797:12)
info: Responding to client with error: {"status":33,"value":{"message":"A new session could not be created. (Original error: Instruments crashed on startup)","origValue":"Instruments crashed on startup"},"sessionId":null}

create session 的问题,是我环境有问题?osx10.9.2,Xcode5.1.1,Simulator - iOS 7.1

有人跟我一样, sometimes it works (run test passed) and sometimes it doesn't, especially the first time start Appium after restart computer,(https://github.com/appium/appium/issues/1384wtf。。。。可是他是 sudo),真是 appium 所以出错的,我没用 sudo 啊。。。

遇到相同问题,怎么解决?

uiauto/bootstrap.js
UIATarget.onAlert = function(alert) {
var alertName = alert.name() || '';
if (alertName.indexOf("Use Your Current Location") !== -1) {
if (bootstrapSettings.useLocationServices) {
alert.buttons()["OK"].tap();
} else {
alert.buttons()[0].tap();
},可以试试

@mandy_hit 我没有解决这个问题,据 Jonathan 在 github 上回复的说法是 “ instruments is the thing that's unstable, usually. ” 另一个主要维护 appium 的开发者也说这是 apple 的一个 bug。

我后来让开发帮忙把 location service 的 alert 延迟出现,一切都好了。只要 alert 不是在应用启动的第一时间出来,都好办。用 capabilities.setCapability("autoAcceptAlerts", true); 或者其他的都行。

匿名 #3 · 2014年08月17日

Mark 一下

@jason 请问这段代码加到哪个位子啊 ,能不能把 bootstrap.js 的内容贴出来

最后怎么解决的?我的是开始用着都挺好的,在不同模拟器之间切换了几次就报这个错了,xcode7.1.1 appium 1.4.13

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