Merge "Catch timeout errors in screenshot scripts"

This commit is contained in:
jenkins-bot 2018-01-13 11:09:24 +00:00 committed by Gerrit Code Review
commit aca63b6189
2 changed files with 29 additions and 7 deletions

View file

@ -11,7 +11,9 @@ module.exports = function ( grunt ) {
var modules = grunt.file.readJSON( 'lib/ve/build/modules.json' ),
screenshotOptions = {
reporter: 'spec',
timeout: 40000,
// TODO: Work out how to catch this timeout and continue.
// For now just make it very long.
timeout: 5 * 60 * 1000,
require: [
function () {
// eslint-disable-next-line no-undef, no-implicit-globals
@ -21,7 +23,9 @@ module.exports = function ( grunt ) {
},
screenshotOptionsAll = {
reporter: 'spec',
timeout: 40000,
// TODO: Work out how to catch this timeout and continue.
// For now just make it very long.
timeout: 5 * 60 * 1000,
require: [
function () {
// eslint-disable-next-line no-undef, no-implicit-globals

View file

@ -1,5 +1,7 @@
/* global seleniumUtils */
/* eslint-disable no-console */
( function () {
'use strict';
var accessKey = process.env.SAUCE_ONDEMAND_ACCESS_KEY,
@ -7,7 +9,8 @@
fs = require( 'fs' ),
Jimp = require( 'jimp' ),
username = process.env.SAUCE_ONDEMAND_USERNAME,
webdriver = require( 'selenium-webdriver' );
webdriver = require( 'selenium-webdriver' ),
TIMEOUT = 40 * 1000;
function createScreenshotEnvironment( test, beforeEach ) {
var clientSize, driver;
@ -29,7 +32,7 @@
driver = new chrome.Driver();
}
driver.manage().timeouts().setScriptTimeout( 40000 );
driver.manage().timeouts().setScriptTimeout( TIMEOUT );
driver.manage().window().setSize( 1200, 1000 );
driver.get( 'https://en.wikipedia.org/wiki/Help:Sample_page?veaction=edit&uselang=' + lang );
@ -132,10 +135,22 @@
}
).then( function ( cs ) {
clientSize = cs;
}, function ( e ) {
// Log error (timeout)
console.error( e.message );
} )
);
if ( beforeEach ) {
driver.wait( driver.executeAsyncScript( beforeEach ) );
driver.manage().timeouts().setScriptTimeout( TIMEOUT );
driver.wait(
driver.executeAsyncScript( beforeEach ).then(
function () {},
function ( e ) {
// Log error (timeout)
console.error( e.message );
}
)
);
}
} );
@ -165,6 +180,7 @@
function runScreenshotTest( name, lang, clientScript, padding ) {
var filename = './screenshots/' + name + '-' + lang + '.png';
driver.manage().timeouts().setScriptTimeout( TIMEOUT );
driver.wait(
driver.executeAsyncScript( clientScript ).then( function ( rect ) {
return driver.takeScreenshot().then( function ( base64Image ) {
@ -176,8 +192,10 @@
fs.writeFile( filename, base64Image, 'base64' );
}
} );
} ),
40000
}, function ( e ) {
// Log error (timeout)
console.error( e );
} )
);
}