// Setting this enables automatic screenshots for when a browser command fails
// It is also used by afterTest for capturig failed assertions.
- screenshotPath: logPath,
+ // We disable it since we have our screenshot handler in the afterTest hook.
+ screenshotPath: null,
// Default timeout for each waitFor* command.
waitforTimeout: 10 * 1000,
*/
beforeTest: function ( test ) {
if ( process.env.DISPLAY && process.env.DISPLAY.startsWith( ':' ) ) {
- let videoPath = filePath( test, this.screenshotPath, 'mp4' );
+ var logBuffer;
+ let videoPath = filePath( test, logPath, 'mp4' );
const { spawn } = require( 'child_process' );
ffmpeg = spawn( 'ffmpeg', [
'-f', 'x11grab', // grab the X11 display
videoPath // output file
] );
+ logBuffer = function ( buffer, prefix ) {
+ let lines = buffer.toString().trim().split( '\n' );
+ lines.forEach( function ( line ) {
+ console.log( prefix + line );
+ } );
+ };
+
ffmpeg.stdout.on( 'data', ( data ) => {
- console.log( `ffmpeg stdout: ${data}` );
+ logBuffer( data, 'ffmpeg stdout: ' );
} );
ffmpeg.stderr.on( 'data', ( data ) => {
- console.log( `ffmpeg stderr: ${data}` );
+ logBuffer( data, 'ffmpeg stderr: ' );
} );
- ffmpeg.on( 'close', ( code ) => {
+ ffmpeg.on( 'close', ( code, signal ) => {
console.log( '\n\tVideo location:', videoPath, '\n' );
- console.log( `ffmpeg exited with code ${code}` );
+ if ( code !== null ) {
+ console.log( `\tffmpeg exited with code ${code} ${videoPath}` );
+ }
+ if ( signal !== null ) {
+ console.log( `\tffmpeg received signal ${signal} ${videoPath}` );
+ }
} );
}
},
return;
}
// save screenshot
- let screenshotPath = filePath( test, this.screenshotPath, 'png' );
- browser.saveScreenshot( screenshotPath );
- console.log( '\n\tScreenshot location:', screenshotPath, '\n' );
+ let screenshotfile = filePath( test, logPath, 'png' );
+ browser.saveScreenshot( screenshotfile );
+ console.log( '\n\tScreenshot location:', screenshotfile, '\n' );
}
};