My app starts with an iOS-generated alert that comes up over the app GUI:
This screen was arrived at in the iOS simulator by clicking on the Inspector button in the Appium.app application window on my Mac. The last part of the console log says:
info: [debug] [INST] 2015-12-15 21:33:32 +0000 Debug: Running system command #15: /Applications/Appium.app/Contents/Resources/node/bin/node /Applications/Appium.app/Contents/Resources/node_modules/appium/submodules/appium-uiauto/bin/command-proxy-client.js /tmp/instruments_sock 2,{“status”:0,“value”:{“UIAApplication”:{“@”:{“name”:“SpringBoard”,“label”:" “,“value”:null,“dom”:null,…
info: [debug] Socket data received (7191 bytes)
info: [debug] Socket data being routed.
info: [debug] Got result from instruments: {“status”:0,“value”:{“UIAApplication”:{”@“:{“name”:“SpringBoard”,“label”:” “,“value”:null,“dom”:null,“enabled”:true,“valid”:true,“visible”:true,“hint”:null,“path”:”/0",“x”:0,“y”:0,“width”:1024.0000335703464,“height”:768.0000447604625},“>”:[{“UIAWindow”:{“@”:{“name”:null,“label”:null,“value”:null,"do
info: [debug] Condition unmet after 10457ms. Timing out.
info: [debug] Cleaning up appium session
info: [debug] Error: App did not have elements
at /Applications/Appium.app/Contents/Resources/
node_modules/appium/lib/devices/ios/ios.js:483:30
at Object.cb [as callback] (/Applications/Appium.app/Contents/Resources/node_modules/appium/lib/devices/ios/ios-controller.js:261:7)
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)
info: [debug] Responding to client with error: {“status”:33,“value”:{“message”:“A new session could not be created. (Original error: App did not have elements)”,“origValue”:“App did not have elements”},“sessionId”:null}
info: ← POST /wd/hub/session 500 26195.783 ms - 172
Which is followed by this error dialog in the Appium.app:
I’ve discussed this with our developers and they say that the alert is generated by iOS because our app uses the iOS APIs to try to access the user’s photos. They have no control over if or when the alert pops up. Surely this can’t be the ONLY iOS app that behaves this way!
Is there a standard way to tell Appium to expect and respond to this alert BEFORE it sees any GUI structure for the app under test?