X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=tests%2Fselenium%2Fwdio.conf.js;h=c8fb8a743533bbdd3fa290e7f74d36702b31bcab;hp=adbd8c352f8888a6be03769b793ca6d60ae5f6bc;hb=7ececd89751310a7d46310b10ca80d5a0aa77528;hpb=dae4c94d893057345f62a3d498fb85c0a54de5a6 diff --git a/tests/selenium/wdio.conf.js b/tests/selenium/wdio.conf.js index adbd8c352f..c8fb8a7435 100644 --- a/tests/selenium/wdio.conf.js +++ b/tests/selenium/wdio.conf.js @@ -217,8 +217,21 @@ exports.config = { // }, // // Function to be executed after a test (in Mocha/Jasmine) or a step (in Cucumber) starts. - // afterTest: function (test) { - // }, + // from https://github.com/webdriverio/webdriverio/issues/269#issuecomment-306342170 + afterTest: function ( test ) { + var filename, filePath; + // if test passed, ignore, else take and save screenshot + if ( test.passed ) { + return; + } + // get current test title and clean it, to use it as file name + filename = encodeURIComponent( test.title.replace( /\s+/g, '-' ) ); + // build file path + filePath = this.screenshotPath + filename + '.png'; + // save screenshot + browser.saveScreenshot( filePath ); + console.log( '\n\tScreenshot location:', filePath, '\n' ); + }, // // Hook that gets executed after the suite has ended // afterSuite: function (suite) {