Repository: cordova-paramedic Updated Branches: refs/heads/master 9482b8b48 -> 1fe2c2d64
CB-12357 Added alert buster Project: http://git-wip-us.apache.org/repos/asf/cordova-paramedic/repo Commit: http://git-wip-us.apache.org/repos/asf/cordova-paramedic/commit/1fe2c2d6 Tree: http://git-wip-us.apache.org/repos/asf/cordova-paramedic/tree/1fe2c2d6 Diff: http://git-wip-us.apache.org/repos/asf/cordova-paramedic/diff/1fe2c2d6 Branch: refs/heads/master Commit: 1fe2c2d649ccfa002c55d0ca2599b76fcb4590da Parents: 9482b8b Author: Alexander Sorokin <alexander.soro...@akvelon.com> Authored: Tue Jan 17 16:34:03 2017 +0300 Committer: Alexander Sorokin <alexander.soro...@akvelon.com> Committed: Tue Jan 17 19:12:01 2017 +0300 ---------------------------------------------------------------------- lib/appium/helpers/wdHelper.js | 36 +++++++++++++++++++++++++++++++++--- lib/paramedic.js | 4 ++-- 2 files changed, 35 insertions(+), 5 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cordova-paramedic/blob/1fe2c2d6/lib/appium/helpers/wdHelper.js ---------------------------------------------------------------------- diff --git a/lib/appium/helpers/wdHelper.js b/lib/appium/helpers/wdHelper.js index 6902970..29b6d17 100644 --- a/lib/appium/helpers/wdHelper.js +++ b/lib/appium/helpers/wdHelper.js @@ -178,16 +178,19 @@ module.exports.tapElementByXPath = function (xpath, driver) { }); }; -module.exports.pollForEvents = function (driver, isAndroid, windowOffset) { +module.exports.pollForEvents = function (driver, platform, windowOffset) { + var isAndroid = platform === 'android'; + var isIOS = platform === 'ios'; if (!windowOffset) { windowOffset = 0; } // polling for new events return driver - //driver.then is not a function, so .sleep(0) .then(function() { - if (!isAndroid) { + if (isIOS) { + return driver.bustAlert(); + } else if (!isAndroid) { return driver; } // for some reason inappbrowser tests tend to leave an active window on android @@ -224,6 +227,29 @@ module.exports.pollForEvents = function (driver, isAndroid, windowOffset) { }); }; +module.exports.bustAlert = function (driver) { + var previousContext; + return driver + .currentContext() + .then(function (context) { + if (context !== 'NATIVE_APP') { + previousContext = context; + } + return driver; + }) + .context('NATIVE_APP') + .acceptAlert() + .then(function alertDismissed() {}, function noAlert() {}) + .then(function () { + if (previousContext) { + return driver + .context(previousContext); + } else { + return driver; + } + }); +}; + module.exports.addFillerImage = function (driver) { var bitmap = fs.readFileSync(path.join(__dirname, '../cordova_logo_thumb.jpg')); var base64str = new Buffer(bitmap).toString('base64'); @@ -289,3 +315,7 @@ wd.addPromiseChainMethod('addFillerImage', function () { wd.addPromiseChainMethod('deleteFillerImage', function (testImagePath) { return module.exports.deleteFillerImage(this, testImagePath); }); + +wd.addPromiseChainMethod('bustAlert', function () { + return module.exports.bustAlert(this); +}); http://git-wip-us.apache.org/repos/asf/cordova-paramedic/blob/1fe2c2d6/lib/paramedic.js ---------------------------------------------------------------------- diff --git a/lib/paramedic.js b/lib/paramedic.js index ad273d6..d440666 100644 --- a/lib/paramedic.js +++ b/lib/paramedic.js @@ -790,10 +790,10 @@ ParamedicRunner.prototype.runSauceTests = function () { .then(function () { logger.normal('cordova-paramedic: connecting to app'); - var isAndroid = self.config.getPlatformId() === 'android'; + var platform = self.config.getPlatformId(); if (!self.config.getUseTunnel()) { pollForResults = setInterval(function () { - driver.pollForEvents(isAndroid) + driver.pollForEvents(platform) .then(function (events) { for (var i = 0; i < events.length; i++) { self.server.emit(events[i].eventName, events[i].eventObject); --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@cordova.apache.org For additional commands, e-mail: commits-h...@cordova.apache.org