From 9f159d757a505af663c5764dd4d44558d15d261d Mon Sep 17 00:00:00 2001 From: Alexander Sorokin Date: Wed, 17 Aug 2016 17:35:23 +0300 Subject: [PATCH] CB-11631 Appium tests: A working fix for a flaky "selection canceled" failure --- appium-tests/android/android.spec.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/appium-tests/android/android.spec.js b/appium-tests/android/android.spec.js index c8b2963..0e00bab 100644 --- a/appium-tests/android/android.spec.js +++ b/appium-tests/android/android.spec.js @@ -400,7 +400,18 @@ describe('Camera tests Android.', function () { return driver .deviceKeyEvent(BACK_BUTTON) // give native app some time to close - .sleep(2000); + .sleep(2000) + // try again! because every ~30th build + // on Sauce Labs this backbutton doesn't work + .elementById('action_bar_title') + .then(function () { + // success means we're still in native app + return driver + .deviceKeyEvent(BACK_BUTTON); + }, function () { + // error means we're already in webview + return driver; + }); }, function () { // error means we're already in webview return driver;