When the wdio configuration has screenshotPath, when a test fail a
screenshot is automatically taken. However there is no support to
specify a filename, we thus went with our own handler in afterTest hook
to have the screenshot names after the full test name.
As a result we had two screenshots taken:
A) CHROME-Error-xxx.png
B) Suite-Sometest.png
Set screenshotPath to null which disable the automatic screenshoting.
Adjust rest of code to use logPath as a base path to save screenshots.
As a side effect, it works around a nasty race condition in the
reporting. The report is generated while some test still has an
afterTest hook running. The report fail to generate and cause nodejs to
exit. The exact fix still has to be figured out though. T216818.
Bug: T216818
Change-Id: I4b53c98bd4de0d9ff850bb883ba899dd1dce0274
// Setting this enables automatic screenshots for when a browser command fails
// It is also used by afterTest for capturig failed assertions.
// 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,
// Default timeout for each waitFor* command.
waitforTimeout: 10 * 1000,
*/
beforeTest: function ( test ) {
if ( process.env.DISPLAY && process.env.DISPLAY.startsWith( ':' ) ) {
*/
beforeTest: function ( test ) {
if ( process.env.DISPLAY && process.env.DISPLAY.startsWith( ':' ) ) {
- let videoPath = filePath( test, this.screenshotPath, 'mp4' );
+ let videoPath = filePath( test, logPath, 'mp4' );
const { spawn } = require( 'child_process' );
ffmpeg = spawn( 'ffmpeg', [
'-f', 'x11grab', // grab the X11 display
const { spawn } = require( 'child_process' );
ffmpeg = spawn( 'ffmpeg', [
'-f', 'x11grab', // grab the X11 display
return;
}
// save screenshot
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' );