@@ -52,6 +52,9 @@ protractorUtil.takeScreenshotOnExpectFail = function (context) {
5252 global . browser . takeScreenshot ( ) . then ( function ( png ) {
5353
5454 var fileName = ( config . capabilities . browserName + '-' + self . result . fullName + '-' + 'expect failure-' + protractorUtil . index ++ ) . replace ( / [ \/ \\ ] / g, ' ' ) ;
55+ if ( fileName . length > 245 ) {
56+ fileName = ( config . capabilities . browserName + '-' + self . result . fullName ) . replace ( / [ \/ \\ ] / g, ' ' ) . substring ( 0 , 230 ) + '-' + 'expect failure-' + protractorUtil . index ++ ;
57+ }
5558 var screenshotPathUserSupplied ;
5659 if ( context . config . screenshotPath ) {
5760 if ( ( ( context . config . screenshotPath . charAt ( context . config . screenshotPath . length - 1 ) ) != '/' ) || ( ( context . config . screenshotPath . charAt ( context . config . screenshotPath . length - 1 ) ) != '\\' ) ) {
@@ -89,6 +92,9 @@ protractorUtil.takeScreenshotOnSpecFail = function (context) {
8992 // take screenshot
9093 global . browser . takeScreenshot ( ) . then ( function ( png ) {
9194 var fileName = ( config . capabilities . browserName + '-' + result . fullName ) . replace ( / [ \/ \\ ] / g, ' ' ) ;
95+ if ( fileName . length > 245 ) {
96+ fileName = ( config . capabilities . browserName + '-' + result . fullName ) . replace ( / [ \/ \\ ] / g, ' ' ) . substring ( 0 , 230 ) ;
97+ }
9298 var stream = fs . createWriteStream ( ( context . config . screenshotPath ? context . config . screenshotPath . replace ( './' , '' ) : 'reports/screenshots/' ) + fileName + '.png' ) ;
9399 stream . write ( new Buffer ( png , 'base64' ) ) ;
94100 stream . end ( ) ;
@@ -199,12 +205,21 @@ protractorUtil.prototype.setup = function () {
199205 var self = this ;
200206
201207 if ( ! this . config . screenshotPath ) {
208+
202209 //creates reports folder if does not exist
203210 var reportsDir = './reports' ;
204211 if ( ! fs . existsSync ( reportsDir ) ) {
205212 fs . mkdirSync ( reportsDir ) ;
206213 }
207214
215+ if ( this . config . clearFoldersBeforeTest ) {
216+ try {
217+ fse . removeSync ( './reports/screenshots' ) ;
218+ } catch ( err ) {
219+ console . error ( err ) ;
220+ }
221+ }
222+
208223 //creates screenshots folder if does not exist
209224 var screenshotDir = './reports/screenshots' ;
210225 if ( ! fs . existsSync ( screenshotDir ) ) {
0 commit comments