screenshots: Catch get/quit errors and log

Stops the test from crashing.

Also set timeout to 10s as tests are rarely successful
after that long.

Change-Id: I8e74dab9693373914c8947f012c3cdcee1dce9f5
This commit is contained in:
Ed Sanders 2020-06-24 20:00:40 +01:00
parent 842a728488
commit a0241f9345

View file

@ -6,7 +6,7 @@ const accessKey = process.env.SAUCE_ONDEMAND_ACCESS_KEY,
Jimp = require( 'jimp' ),
username = process.env.SAUCE_ONDEMAND_USERNAME,
webdriver = require( 'selenium-webdriver' ),
TIMEOUT = 40 * 1000;
TIMEOUT = 10 * 1000;
function createScreenshotEnvironment( test, beforeEach ) {
let clientSize, driver;
@ -31,7 +31,10 @@ function createScreenshotEnvironment( test, beforeEach ) {
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 );
driver.get( 'https://en.wikipedia.org/wiki/Help:Sample_page?veaction=edit&uselang=' + lang )
.then( null, function ( e ) {
console.error( e.message );
} );
driver.wait(
driver.executeAsyncScript(
require( './screenshots-client/utils.js' )
@ -57,7 +60,10 @@ function createScreenshotEnvironment( test, beforeEach ) {
} );
test.afterEach( function () {
driver.quit();
driver.quit()
.then( null, function ( e ) {
console.error( e.message );
} );
} );
function cropScreenshot( filename, imageBuffer, rect, padding ) {