@adrianmatean - now I just saw that the solution is great for iOS 8 , but it doesn't work on iOS 9+
getting the next error :
info: --> POST /wd/hub/session/98bc8b28-3756-4fc2-b40e-df2d92f3ba33/execute {"script":"var x = target.deactivateAppForDuration(5); var MAX_RETRY=10, retry_count = 0; while (!x && retry_count < MAX_RETRY) { x = target.deactivateAppForDuration(5); retry_count += 1}; x","args":[]}
info: [debug] Pushing command to appium work queue: "var x = target.deactivateAppForDuration(5); var MAX_RETRY=10, retry_count = 0; while (!x && retry_count < MAX_RETRY) { x = target.deactivateAppForDuration(5); retry_count += 1}; x"
info: [debug] Sending command to instruments: var x = target.deactivateAppForDuration(5); var MAX_RETRY=10, retry_count = 0; while (!x && retry_count < MAX_RETRY) { x = target.deactivateAppForDuration(5); retry_count += 1}; x
info: [debug] [INST] 2015-11-03 13:23:50 +0000 Debug: Got new command 3 from instruments: var x = target.deactivateAppForDuration(5); var MAX_RETRY=10, retry_count = 0; while (!x && retry_count < MAX_RETRY) { x = target.deactivateAppForDuration(5); retry_count += 1}; x
info: [debug] [INST] 2015-11-03 13:23:50 +0000 Debug: evaluating var x = target.deactivateAppForDuration(5); var MAX_RETRY=10, retry_count = 0; while (!x && retry_count < MAX_RETRY) { x = target.deactivateAppForDuration(5); retry_count += 1}; x
info: [debug] [INST] 2015-11-03 13:23:50 +0000 Debug: target.deactivateAppForDuration("5")
info: [debug] [INST] 2015-11-03 13:23:51 +0000 Debug: target.deactivateAppForDuration("5")
info: [debug] [INST] 2015-11-03 13:24:03 +0000 Debug: -[UIAElementNil _prepareForAction:]: unrecognized selector sent to instance 0x7fc04151ab00
info: [debug] [INST] 2015-11-03 13:24:03 +0000 Error: VerboseError: -[UIAElementNil _prepareForAction:]: unrecognized selector sent to instance 0x7fc04151ab00
info: [debug] Socket data received (116 bytes)
info: [debug] Socket data being routed.
info: [debug] Got result from instruments: {"status":17,"value":"-[UIAElementNil _prepareForAction:]: unrecognized selector sent to instance 0x7fc04151ab00"}
info: [debug] Responding to client with error: {"status":17,"value":{"message":"An error occurred while executing user supplied JavaScript.","origValue":"-[UIAElementNil _prepareForAction:]: unrecognized selector sent to instance 0x7fc04151ab00"},"sessionId":"98bc8b28-3756-4fc2-b40e-df2d92f3ba33"}
info: <-- POST /wd/hub/session/98bc8b28-3756-4fc2-b40e-df2d92f3ba33/execute 500 13039.869 ms - 251
info: [debug] [INST] 2015-11-03 13:24:03 +0000 Error: Error during eval: deactivateAppForDuration@[native code]
eval code
eval@[native code]
startProcessing@file:///Applications/Appium.app/Contents/Resources/node_modules/appium/E3E05890-6927-4351-B529-68E7795CF5A9/bootstrap-4e580d338a12229a.js:2702:30
bootstrap@file:///Applications/Appium.app/Contents/Resources/node_modules/appium/E3E05890-6927-4351-B529-68E7795CF5A9/bootstrap-4e580d338a12229a.js:2770:31
global code@file:///Applications/Appium.app/Contents/Resources/node_modules/appium/E3E05890-6927-4351-B529-68E7795CF5A9/bootstrap-4e580d338a12229a.js:2779:10