Unable to handle Notifications in iOS native app

Configurations used
Mac OSX Yosemite
Appium 1.3.3 installed from source
iOS simulator - iPhone 6 on iOS 8.1
Xcode 6.1

Problem
When I install iOS native app on simulator/device through Appium or manually , a notification is displayed as below having “Dont Allow” and OK button

When this appears Appium crashes. The Inspector also does not launch.So i am unable to find the properties of these buttons so that i can click them

Tried the following

  • set acceptAllAlerts to true. Did not work
  • set locationServicesAuthorized to true . Did not work
  • set locationServicesAuthorized to false . Did not work
  • Tried by using sendkeys(Keys.return). Did not work

Appium Log
info: [debug] Starting Appium in pre-launch mode
info: Pre-launching app
info: [debug] Using local app from command line: /Users/iOS/build/Release-iphonesimulator/Mobile.app
info: [debug] Creating new appium session dc021ef6-483f-4359-a1a7-e4c0d0227fa7
info: [debug] Removing any remaining instruments sockets
info: [debug] Cleaned up instruments socket /tmp/instruments_sock
info: [debug] Setting Xcode folder
info: [debug] Setting Xcode version
info: [debug] Setting iOS SDK Version
info: [debug] Getting sdk version from xcrun with a timeout
info: [debug] iOS SDK Version set to 8.1
info: [debug] Checking whether instruments supports our device string
info: [debug] Getting list of devices instruments supports
info: [debug] Instruments is at: /Applications/Xcode.app/Contents/Developer/usr/bin/instruments
info: [debug] Getting device string from opts: {“forceIphone”:false,“forceIpad”:false,“xcodeVersion”:“6.1”,“iOSSDKVersion”:“8.1”,“deviceName”:“iPhone 6”,“platformVersion”:null}
info: [debug] fixDevice is on
info: [debug] Final device string is: ‘iPhone 6 (8.1 Simulator)’
info: [debug] iOS sim UDID is 0128280B-D11B-4975-B315-993753BA6B06
info: [debug] Detecting automation tracetemplate
info: [debug] Not auto-detecting udid, running on sim
info: [debug] Could not parse plist file (as binary) at /Users/iOS/build/Release-iphonesimulator/Mobile.app/en.lproj/Localizable.strings
info: Will try to parse the plist file as XML
parseFileSync() is deprecated. Use parseStringSync() instead.
info: [debug] Could not parse plist file (as XML) at /Users/iOS/build/Release-iphonesimulator/Mobile.app/en.lproj/Localizable.strings
warn: Could not parse app Localizable.strings; assuming it doesn’t exist
info: [debug] Getting bundle ID from app
info: [debug] Parsed app Info.plist (as binary)
info: [debug] Creating instruments
info: On some xcode 6 platforms, instruments-without-delay does not work. If you experience this, you will need to re-run appium with the --native-instruments-lib flag
info: [debug] Preparing uiauto bootstrap
info: [debug] Dynamic bootstrap dir: /Users/Library/Application Support/appium/bootstrap
info: [debug] Dynamic env: {“nodePath”:“/Applications/Appium.app/Contents/Resources/node/bin/node”,“commandProxyClientPath”:“/Applications/Appium.app/Contents/Resources/node_modules/appium/node_modules/appium-uiauto/bin/command-proxy-client.js”,“instrumentsSock”:“/tmp/instruments_sock”,“interKeyDelay”:null,“justLoopInfinitely”:false,“autoAcceptAlerts”:false}
info: [debug] Dynamic bootstrap code: // This file is automatically generated. Do not manually modify!

info: [debug] Dynamic bootstrap path: /Users/Library/Application Support/appium/bootstrap/bootstrap-60f23230385b0cfa.js
info: [debug] Reusing dynamic bootstrap: /Users/Library/Application Support/appium/bootstrap/bootstrap-60f23230385b0cfa.js
info: [debug] Getting device string from opts: {“forceIphone”:false,“forceIpad”:false,“xcodeVersion”:“6.1”,“iOSSDKVersion”:“8.1”,“deviceName”:“iPhone 6”,“platformVersion”:null}
info: [debug] fixDevice is on
info: [debug] Final device string is: ‘iPhone 6 (8.1 Simulator)’
info: [debug] We’re on iOS7.1+ so forcing defaultDevice on

info: [debug] Getting device string from opts: {“forceIphone”:false,“forceIpad”:false,“xcodeVersion”:“6.1”,“iOSSDKVersion”:“8.1”,“deviceName”:“iPhone 6”,“platformVersion”:null}
info: [debug] fixDevice is on
info: [debug] Final device string is: ‘iPhone 6 (8.1 Simulator)’
info: [debug] Parsed app Info.plist (as binary)
info: [debug] Wrote new app Info.plist with device type
info: [debug] Checking whether we need to set app preferences
info: [debug] Running ios sim reset flow
info: [debug] Killing the simulator process
info: [debug] Killall iOS Simulator

info: [debug] Killing any other simulator daemons

info: [debug] Cleaning sim data files
info: [debug] Executing: xcrun simctl erase 0128280B-D11B-4975-B315-993753BA6B06

info: [debug] Cleaning app data files

warn: Applications directory /Users/Library/Developer/CoreSimulator/Devices/0128280B-D11B-4975-B315-993753BA6B06/data/Applications doesn’t exist. Have you run this simulator before?
info: Couldn’t find app directories to delete. Probably it’s not installed
info: [debug] Resetting Content and Settings for Simulator

info: [debug] Executing: xcrun simctl erase 0128280B-D11B-4975-B315-993753BA6B06

info: [debug] Not setting locale

info: [debug] No iOS / app preferences to set
info: [debug] Starting iOS 8.* simulator log capture

info: [debug] Not pre-launching simulator

info: [debug] No device id or app, not installing to real device.
info: [debug] Starting command proxy.
info: [debug] Instruments socket server started at /tmp/instruments_sock
info: [debug] Starting instruments

info: [debug] Instruments is at: /Applications/Xcode.app/Contents/Developer/usr/bin/instruments
info: Launching instruments
info: [debug] Attempting to run app on iPhone 6 (8.1 Simulator)
info: [debug] Spawning instruments with command: /Applications/Xcode.app/Contents/Developer/usr/bin/instruments -t /Applications/Xcode.app/Contents/Applications/Instruments.app/Contents/PlugIns/AutomationInstrument.xrplugin/Contents/Resources/Automation.tracetemplate -D /tmp/appium-instruments/instrumentscli0.trace -w “iPhone 6 (8.1 Simulator)” “/Users/iOS/build/Release-iphonesimulator/Mobile.app” -e UIASCRIPT “/Users/Library/Application Support/appium/bootstrap/bootstrap-60f23230385b0cfa.js” -e UIARESULTSPATH /tmp/appium-instruments
info: [debug] And extra without-delay env: {“DYLD_INSERT_LIBRARIES”:“/Applications/Appium.app/Contents/Resources/node_modules/appium/node_modules/appium-instruments/thirdparty/iwd6/InstrumentsShim.dylib”,“LIB_PATH”:“/Applications/Appium.app/Contents/Resources/node_modules/appium/node_modules/appium-instruments/thirdparty/iwd6”}
info: [debug] And launch timeouts (in ms): {“global”:90000}

info: [debug] [INST] Waiting for device to boot…

info: [debug] [INST] 2014-11-21 11:25:05 +0000 Fail: Could not start script, target application is not frontmost.

info: [debug] [INST] Instruments Trace Complete (Duration : 35.322132s; Output : /tmp/appium-instruments/instrumentscli0.trace)

info: [debug] [INSTSERVER] Instruments exited with code 0

info: [debug] Killall instruments

info: [debug] Instruments crashed on startup
info: [debug] Attempting to retry launching instruments, this is retry #1
info: [debug] Killall iOS Simulator

info: Launching instruments

info: [debug] Attempting to run app on iPhone 6 (8.1 Simulator)

info: [debug] Spawning instruments with command: /Applications/Xcode.app/Contents/Developer/usr/bin/instruments -t /Applications/Xcode.app/Contents/Applications/Instruments.app/Contents/PlugIns/AutomationInstrument.xrplugin/Contents/Resources/Automation.tracetemplate -D /tmp/appium-instruments/instrumentscli0.trace -w “iPhone 6 (8.1 Simulator)” “/Users/iOS/build/Release-iphonesimulator/Mobile.app” -e UIASCRIPT “/Users/Library/Application Support/appium/bootstrap/bootstrap-60f23230385b0cfa.js” -e UIARESULTSPATH /tmp/appium-instruments
info: [debug] And extra without-delay env: {“DYLD_INSERT_LIBRARIES”:“/Applications/Appium.app/Contents/Resources/node_modules/appium/node_modules/appium-instruments/thirdparty/iwd6/InstrumentsShim.dylib”,“LIB_PATH”:“/Applications/Appium.app/Contents/Resources/node_modules/appium/node_modules/appium-instruments/thirdparty/iwd6”}
info: [debug] And launch timeouts (in ms): {“global”:90000}

info: [debug] [INST] Waiting for device to boot…

info: [debug] [INST STDERR] Instruments Trace Error : Target failed to run: The operation couldn’t be completed. (FBSOpenApplicationErrorDomain error 8.) : Failed to launch process with bundle identifier ‘com.enterprise’

info: [debug] [INSTSERVER] Instruments exited with code 253

info: [debug] Killall instruments
info: [debug] Instruments crashed on startup

Thanks for you time in advance
Srinidhi

I never had this problem so i’m not sure it’ll work or not. Tap on OK while you are trying it with inspector and get the elements for the test cases. When you try with code(test case code) tap on element by name “OK” first then proceed to other element.
I hope it will work.

Thanks for your reply @pr4bh4sh…the problem is inspector never functions when this notification displays…i feel this notification is thrown by iphone simulator operating system and hence Appium or inspector have no control on it

What i meant by clicking on OK button is manually not by Appium inspector.
Or just install it manually, accept whatever notification it gives and launch by bundle id of the application(do not install it by Appium inspector).
I know its not the perfect approach but you will have something to show at the end of the day. :smile:

I’m experiencing the exact same issue. It appears to be an Xcode 6.1 / iOS8.1 simulator issue with apps that have notification functionality.

80% of the time the notifications alert dialog causes instruments / Appium to not find the AUT, thus the test execution fails. When by chance the session does get successfully created I have code that can successfully dismiss the alert and my tests execute.

FYI - I logged a bug in Git and it looks like effort was already made towards solving this.

Not that it’s a perfect workaround, but the cap for automatically accepting alerts is autoAcceptAlerts, not acceptAllAlerts. You could try that in the meantime while waiting for a fix.

1 Like