CB-10639 Appium tests: Added some timeouts,

Taking a screenshot on failure,
Retry taking a picture up to 3 times,
Try to restart the Appium session if it's lost
This commit is contained in:
Alexander Sorokin
2016-02-22 18:37:41 +03:00
parent f792aaacc3
commit c1948fc0d4
5 changed files with 176 additions and 82 deletions
+1 -1
View File
@@ -1,4 +1,4 @@
/*jslint node: true, plusplus: true */
/*jshint node: true */
'use strict';
var cameraConstants = require('../../www/CameraConstants');
+37
View File
@@ -0,0 +1,37 @@
/* jshint node: true */
'use strict';
var path = require('path');
var screenshotPath = global.SCREENSHOT_PATH || path.join(__dirname, '../../appium_screenshots/');
function generateScreenshotName() {
var date = new Date();
var month = date.getMonth() + 1;
var day = date.getDate();
var hour = date.getHours();
var min = date.getMinutes();
var sec = date.getSeconds();
month = (month < 10 ? "0" : "") + month;
day = (day < 10 ? "0" : "") + day;
hour = (hour < 10 ? "0" : "") + hour;
min = (min < 10 ? "0" : "") + min;
sec = (sec < 10 ? "0" : "") + sec;
return date.getFullYear() + '-' + month + '-' + day + '_' + hour + '.' + min + '.' + sec + '.png';
}
module.exports.saveScreenshot = function (driver) {
var oldContext;
return driver
.currentContext()
.then(function (cc) {
oldContext = cc;
})
.context('NATIVE_APP')
.saveScreenshot(screenshotPath + generateScreenshotName())
.then(function () {
return driver.context(oldContext);
});
};
+3 -4
View File
@@ -1,4 +1,4 @@
/*jslint node: true, plusplus: true */
/* jshint node: true */
'use strict';
var wd = global.WD || require('wd');
@@ -24,11 +24,10 @@ module.exports.getDriver = function (platform, callback) {
}
driver = wd.promiseChainRemote(serverConfig);
module.exports.configureLogging(driver);
driver.init(driverConfig).setImplicitWaitTimeout(10000)
return driver.init(driverConfig).setImplicitWaitTimeout(10000)
.sleep(20000) // wait for the app to load
.then(callback);
return driver;
};
module.exports.getWD = function () {