mirror of
https://github.com/appium/appium.git
synced 2026-02-13 21:39:49 -06:00
added screenshotWaitTimeout cap
This commit is contained in:
@@ -79,3 +79,4 @@
|
||||
|`interKeyDelay`| The delay, in ms, between keystrokes sent to an element when typing.|e.g., `100`|
|
||||
|`showIOSLog`| Whether to show any logs captured from a device in the appium logs. Default `false`|`true` or `false`|
|
||||
|`sendKeyStrategy`| strategy to use to type test into a test field. Simulator default: `oneByOne`. Real device default: 'grouped' |`oneByOne`, `grouped` or setValue|
|
||||
|`screenshotWaitTimeout`| Max timeout in sec to wait for a screenshot to be generated. default: 10 |e.g., `5`|
|
||||
|
||||
@@ -1232,24 +1232,26 @@ iOSController.getScreenshot = function (cb) {
|
||||
function (cb) { this.getOrientation(function () { cb(); }); }.bind(this),
|
||||
function (cb) { this.proxy(command, cb); }.bind(this),
|
||||
function (response, cb) {
|
||||
var data = null;
|
||||
var count = 0;
|
||||
var data;
|
||||
var screenshotWaitTimeout = (this.args.screenshotWaitTimeout || 10) * 1000;
|
||||
logger.debug('Waiting ' + screenshotWaitTimeout + ' ms for screenshot to ge generated.');
|
||||
var startMs = Date.now();
|
||||
var lastErr;
|
||||
async.until(
|
||||
function () { return data; },
|
||||
function () { return data || Date.now() - startMs > screenshotWaitTimeout; },
|
||||
function (cb) {
|
||||
setTimeout(function () {
|
||||
fs.readFile(shotPath, function (err, _data) {
|
||||
if (err && ++count > 20) {
|
||||
return cb(new Error("Timed out waiting for screenshot file. " + err.toString()));
|
||||
}
|
||||
if (!err) {
|
||||
data = _data;
|
||||
}
|
||||
lastErr = err;
|
||||
if (!err) { data = _data; }
|
||||
cb();
|
||||
});
|
||||
}, 300);
|
||||
},
|
||||
function (err) {
|
||||
if (!data) {
|
||||
return cb(new Error("Timed out waiting for screenshot file. " + (lastErr || '').toString()));
|
||||
}
|
||||
cb(err, response, data);
|
||||
}
|
||||
);
|
||||
|
||||
@@ -3,27 +3,43 @@
|
||||
var setup = require("../../common/setup-base");
|
||||
|
||||
describe('safari - screenshots @skip-ios6', function () {
|
||||
var driver;
|
||||
setup(this, {browserName: 'safari'}).then(function (d) { driver = d; });
|
||||
describe('default' ,function () {
|
||||
var driver;
|
||||
setup(this, {browserName: 'safari'}).then(function (d) { driver = d; });
|
||||
|
||||
it('should get an app screenshot', function (done) {
|
||||
driver
|
||||
.takeScreenshot()
|
||||
.should.eventually.exist
|
||||
it('should get an app screenshot', function (done) {
|
||||
driver
|
||||
.takeScreenshot()
|
||||
.should.eventually.exist
|
||||
.nodeify(done);
|
||||
});
|
||||
it('should get an app screenshot in landscape mode', function (done) {
|
||||
driver.takeScreenshot().then(function (screenshot1) {
|
||||
screenshot1.should.exist;
|
||||
return driver
|
||||
.setOrientation("LANDSCAPE")
|
||||
// A useless error does often exist here, let's ignore it
|
||||
.catch(function () {})
|
||||
.takeScreenshot().then(function (screenshot2) {
|
||||
screenshot2.should.exist;
|
||||
screenshot2.should.not.eql(screenshot1);
|
||||
});
|
||||
}).sleep(3000) // cooldown
|
||||
.nodeify(done);
|
||||
});
|
||||
});
|
||||
it('should get an app screenshot in landscape mode', function (done) {
|
||||
driver.takeScreenshot().then(function (screenshot1) {
|
||||
screenshot1.should.exist;
|
||||
return driver
|
||||
.setOrientation("LANDSCAPE")
|
||||
// A useless error does often exist here, let's ignore it
|
||||
.catch(function () {})
|
||||
.takeScreenshot().then(function (screenshot2) {
|
||||
screenshot2.should.exist;
|
||||
screenshot2.should.not.eql(screenshot1);
|
||||
});
|
||||
}).sleep(3000) // cooldown
|
||||
.nodeify(done);
|
||||
|
||||
describe('setting screenshotWaitTimeout' ,function () {
|
||||
var driver;
|
||||
setup(this, {browserName: 'safari', screenshotWaitTimeout: 5})
|
||||
.then(function (d) { driver = d; });
|
||||
|
||||
it('should get an app screenshot', function (done) {
|
||||
driver
|
||||
.takeScreenshot()
|
||||
.should.eventually.exist
|
||||
.nodeify(done);
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user