Hi guys,
i’m using driver.runAppInBackground(5) method to hide app in background, But how can i launch the app running from background
I’m using iOS
Hi guys,
i’m using driver.runAppInBackground(5) method to hide app in background, But how can i launch the app running from background
I’m using iOS
Have you tried ?
launchApp()
http://appium.github.io/java-client/io/appium/java_client/AppiumDriver.html
Telmo,
App automatically launched after the time mentioned in runappinBackGround(5) method
Thx
yes, that happens
though it is not happening with ios8 …any other alternative do we hv to achieve the same?
@Telmo_Cardoso please Reply…
Didn’t test yet with ios8.
And I search for a issue and in fact there is one, if you think its related to appium, re-open as jlipps said.
Hi all,
Fighting the issue for a while now, iOS8.2, Appium 1.4.0. I see the issue on real device, not sure about simulators.
I have found a workaround provided by calabash. It works for me.
The original issue can be found at https://github.com/calabash/calabash-ios/commit/6935245605d1fd44c223155972703e89247857ec
Apparently retrying the uia command does the trick.
I replaced the original
driver.runAppInBackground(2);
with
JavascriptExecutor jse = (JavascriptExecutor) driver;
jse.executeScript("var x = target.deactivateAppForDuration(2); var MAX_RETRY=5, retry_count = 0; while (!x && retry_count < MAX_RETRY) { x = target.deactivateAppForDuration(2); retry_count += 1}; x");
@adrianmatean - Great solution !!
many thanks
@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
Agreed - the target.deactivateAppForDuration
technique does not work on iOS 9.1 for me. Same error as mentioned above
015-11-10 16:34:28:777 - info: [debug] [INST] 2015-11-10 11:02:39 +0000 Debug: Running system command
#150: /usr/local/Cellar/node/4.2.0/bin/node /usr/local/lib/node_modules/a
ppium/node_modules/appium-uiauto/bin/command-proxy-client.js /tmp/instruments_sock 2,{"status":0,"value":""}...
2015-11-10 16:34:29:944 - info: [debug] [INST] 2015-11-10 11:02:41 +0000 Debug: Got new command 150 from instruments: UIATarget.localTarget().deactivateAppForDuration(1)
2015-11-10 16:34:29:962 - info: [debug] [INST] 2015-11-10 11:02:41 +0000 Debug: evaluating UIATarget.localTarget().deactivateAppForDuration(1)
2015-11-10 16:34:29:982 - info: [debug] [INST] 2015-11-10 11:02:41 +0000 Debug: target.deactivateAppForDuration("1")
2015-11-10 16:34:33:036 - info: [debug] [INST] 2015-11-10 11:02:44 +0000 Debug: target.frontMostApp().alert().buttons()[1].tap()
2015-11-10 16:34:33:317 - info: [debug] [INST] 2015-11-10 11:02:44 +0000 Debug: Waiting for alert to close...
2015-11-10 16:34:33:601 - info: [debug] [INST] 2015-11-10 11:02:45 +0000 Debug: Waiting for alert to close...
2015-11-10 16:34:40:692 - info: [debug] [INST] 2015-11-10 11:02:52 +0000 Debug: -[UIAElementNil _prepareForAction:]: unrecognized selector sent to instance 0x1666ff10
2015-11-10 16:34:41:214 - info: [debug] Socket data received (112 bytes)
2015-11-10 16:34:41:215 - info: [debug] Socket data being routed.
2015-11-10 16:34:41:215 - info: [debug] Got result from instruments: {"status":17,"value":"-[UIAElementNil _prepareForAction:]: unrecognized selector sent to instance 0x1666ff10"}
2015-11-10 16:34:41:215 - 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 0x1666ff10"},"sessionId":"ca1d43a1-d055-4fa2-9c15-22e7e4523fac"}
2015-11-10 16:34:41:217 - info: <-- POST /wd/hub/session/ca1d43a1-d055-4fa2-9c15-22e7e4523fac/execute 500 12504.070 ms - 247
2015-11-10 16:34:44:953 - info: [debug] [INST] 2015-11-10 11:02:52 +0000 Error: VerboseError: -[UIAElementNil _prepareForAction:]: unrecognized selector sent to instance 0x1666ff10
2015-11-10 16:34:45:121 - info: [debug] [INST] 2015-11-10 11:02:52 +0000 Error: Error during eval: deactivateAppForDuration@[native code]
eval code
eval@[native code]
###UPDATE:###
016-02-24 10:21:11:805 - 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 0x136e56340"},"sessionId":"69d433e1-ac0d-498b-af23-6e58efbbc43f"}
RunAppInBackground actually relaunches the app, but I want it to resume the same screen. How to do it?
sendKeyEvent(3) does send it to home but how to come to foreground to resume the same screen?
@adrianmatean @Telmo_Cardoso @jagadeeshkotha
runappinBackGround(5) is working for me , here after the app launches i want to be script must start running
But it was saying activity in the screen is not matching
Please help me out to handle this situation?
This is a thread for iOS Appium; I suggest you open a new thread for Android Appium so as to not confuse the issue.
it reopens the app but app does not start from same page where we have closed it.