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");