gkushang / cucumber-html-reporter

Generates Cucumber HTML reports in three different themes
MIT License
234 stars 156 forks source link

Random numbers are appended in filename cucumber_report.json while running on remote browsers. #163

Open venkyranga84 opened 5 years ago

venkyranga84 commented 5 years ago

If I am running the test locally, I see the json file created by name "cucumber_report.json". Whereas, when I try to run on remote browsers(saucelabs/other remote browsers), I see the json filename has some randon numbers appended to it(for example: cucumber_report.36502.json) and the reporter.generate method is throwing below error:-

Unable to parse cucumberjs output into json: '/Users/aye626/WebstormProjects/New/reports/json/cucumber_report.json' { Error: /Users/aye626/WebstormProjects/New/reports/json/cucumber_report.json: ENOENT: no such file or directory, open '/Users/aye626/WebstormProjects/New/reports/json/cucumber_report.json' at Object.openSync (fs.js:436:3) at Object.readFileSync (fs.js:341:35) at Object.readFileSync (/Users/aye626/WebstormProjects/New/node_modules/jsonfile/index.js:67:22) errno: -2, syscall: 'open', code: 'ENOENT', path: '/Users/aye626/WebstormProjects/New/reports/json/cucumber_report.json' }

I tried using regular expression like "cucumber_report.*" in jsonFile parameter. But no luck so far. Any help is greatly appreciated.

vijayphalke commented 5 years ago

Can someone please help on this? I am also started facing problem for the cucumber_report.json file, which is generated automatically using cucumber-html-reporter plugin mentioned under https://www.npmjs.com/package/cucumber-html-reporter. Since the filename is appended with random numbers like "cucumber_report.28652.json", it is not possible for report generator to generate html report, because it is looking for "cucumber_report.json" filename. This was working well for me but somehow stopped working...The only change I did is updated Chrome version. Any help on this would be appreciated.

hujunhaorobert commented 4 years ago

I have a fix in the above PR, let try to get the fix integrated into new npm release

miguelbridges commented 4 years ago

I am running into an issue with reporter appending Random numbers to jsonFile. I pulled latest 5.2.0 and 5.0.1 (in which the fix was placed) and it is still happening, but only with Firefox? I recently updated to Firefox Quantum 68.11 esr, I believe this may be the issue, but not sure why/how. As it was functioning correctly with ffx52.

The strange thing is its working for Chrome and IE, but when Firefox runs script, it adds random numbers such as cucumber_report.3214.json. But in my config I have only cucumber_report.json, so it must not be overwriting only when initializing for firefox. I am not sure why, but it seems be be happening once the test init(hooks) happen, but I did not place any code there. I have attached my Chrome/ IE and Firefox Configs.

Here are my versions of everything I am using: node: 8.11.3 npm: 6.14.6 protractor: 5.4.3 typescript: 3.6.4 cucumber: 5.1.0 cucumber-html-reporter: 5.2.0 (currently) have used (3.0.4 // 4.0.4 // 5.1.0 // 5.2.0) : which makes me think its browser version?

Really just reaching out to see if anyone else is seeing this with firefox and has a work around and or if there is anything specific to the reporter that is causing this or if anyone elses can reproduce?

miguelbridges commented 4 years ago

For some reason file upload isnt working so see below:

----- CHROME CONFIG ------ import { Config, browser } from 'protractor'; import * as reporter from 'cucumber-html-reporter';

export let config: Config = { // seleniumAddress: 'http://localhost:4444/wd/hub', //directConnect: true, baseUrl: 'http://localhost:4200/',

framework: 'custom', // path relative to the current config file SELENIUM_PROMISE_MANAGER: true, frameworkPath: require.resolve( 'protractor-cucumber-framework' ), seleniumServerJar: '../Jars/selenium-server-standalone-3.5.0.jar', geckoDriver: '../Jars/geckodriver.exe', chromeDriver: '../Jars/chromedriver.exe', ignoreUncaughtExceptions: true,

maxSessions: 1,

localSeleniumStandaloneOpts: { jvmArgs: [ "-Dwebdriver.ie.driver=./Jars/IEDriverServer-3.4.0.exe" ],

},

allScriptsTimeout: 60000,

restartBrowserBetweenTests: true,

// plugins: [ // failFast.init(), // ],

// require feature files specs: [ '../e2e/features/1_UCDP_Flow.feature', //'../e2e/features/LCA_Flow.feature',

],

cucumberOpts: { //tags: "@LCAflow95i", tags: "@BUCDP", format: 'json:reports/json/Chrome/cucumber_report.json', reportName: 'PORTAL REPORT', pageFooter: '

Generated by Portal Team

', // Step Definition require: [ './e2e/specs' ]

},

onPrepare: function () { // let width = 1024; // let height = 768; //browser.driver.manage().window().setSize(width, height); browser.manage().window().maximize(); // maximize the browser before executing the feature files
browser.driver.manage().deleteAllCookies(); browser.ignoreSynchronization = true; browser.waitForAngular(); },

onComplete: () => { var options = { theme: 'bootstrap', jsonFile: 'reports/json/Chrome/cucumber_report.json', output: 'reports/html/Chrome/cucumber_report.html', reportSuiteAsScenarios: true, launchReport: true, metadata: { "Application": "LCA Rules", "Test Environment": "UAT", "Browser": "Chrome 78", "Platform": "Windows 7", "Parallel": "Scenarios", "Executed": "Non Prod VDI"

  }
};
reporter.generate( options );

},

capabilities: {

'browserName': 'chrome',
chromeOptions: {
  'useAutomationExtension': false,
  //'args': ['show-fps-counter=true'],
}

} };


-------- FIREFOX CONFIG --------------------

import { Config, browser } from 'protractor'; import * as reporter from 'cucumber-html-reporter';

var FirefoxProfile = require( 'firefox-profile' ); var q = require( 'q' );

export let config: Config = {

getMultiCapabilities: getFirefoxProfile, framework: 'custom', // path relative to the current config file SELENIUM_PROMISE_MANAGER: true, frameworkPath: require.resolve( 'protractor-cucumber-framework' ), seleniumServerJar: '../Jars/selenium-server-standalone-3.5.0.jar', geckoDriver: '../Jars/geckodriver.exe', chromeDriver: '../Jars/chromedriver.exe', ignoreUncaughtExceptions: true, maxSessions: 1,

localSeleniumStandaloneOpts: { jvmArgs: [ "-Dwebdriver.ie.driver=./Jars/IEDriverServer-3.4.0.exe" ],

},

allScriptsTimeout: 60000,

restartBrowserBetweenTests: true,

// require feature files specs: [ '../e2e/features/*.feature', ],

cucumberOpts: { compiler: "ts:ts-node/register", format: 'json:reports/json/Firefox/cucumber_report.json', reportName: 'LCA REPORT', pageFooter: '

Generated by LCA Rules Team

', require: [ './e2e/specs' ], tags: '@LCA_Lender15_Flow', //'@UCDP',//"@LCA_SuperUser_Flow", // '@LCA_Lender15_Flow', // '@LCA_Lender17_Flow',

},

onPrepare: function () { browser.sleep( 2000 ) browser.manage().window().maximize(); // maximize the browser before executing the feature files
browser.driver.manage().deleteAllCookies(); browser.driver.manage().timeouts().implicitlyWait( 30 ) browser.ignoreSynchronization = true; browser.waitForAngular(); browser.waitForAngularEnabled( false ); },

onComplete: () => { let options = { theme: 'bootstrap', jsonFile: 'reports/json/Firefox/cucumber_report.json', //jsonDir: 'reports/json/Firefox/', output: 'reports/html/Firefox/cucumber_report.html', reportSuiteAsScenarios: true, ignoreBadJsonFile: true, launchReport: true, metadata: { "Application": "LCA Rules", "Test Environment": "UAT", "Browser": "Firefox 69.11.0esr", "Platform": "Windows 7", "Parallel": "Scenarios", "Executed": "Non Prod VDI"

  }
};
reporter.generate( options );

},

capabilities: { 'browserName': 'firefox', 'javascriptEnabled': true, 'ignoreProtectedModeSettings': true, 'disable-popup-blocking': true, 'unexpectedAlertBehaviour': 'accept', 'marionette': true, 'directConnect': true,

}

};

function getFirefoxProfile () { "use strict"; var deferred = q.defer(); var firefoxProfile = new FirefoxProfile(); firefoxProfile.setPreference( "browser.download.folderList", 2 ); firefoxProfile.setPreference( "browser.download.manager.showWhenStarting", false ); firefoxProfile.setPreference( "browser.download.dir", '/tmp' ); firefoxProfile.setPreference( "browser.helperApps.neverAsk.saveToDisk", "application/vnd.openxmlformats-officedocument.wordprocessingml.document" );

firefoxProfile.encoded( function ( encodedProfile ) { var multiCapabilities = [ { browserName: 'firefox', firefox_profile: encodedProfile } ]; deferred.resolve( multiCapabilities ); } ); return deferred.promise; }

basid09 commented 3 years ago

Same here, i see the issue when we use 'maxSessions', i.e run features in parallel.