mlison / protractor-jasmine2-screenshot-reporter

Protractor screenshot reporter for Jasmine2
https://www.npmjs.com/package/protractor-jasmine2-screenshot-reporter
MIT License
81 stars 79 forks source link

Screenshot files are empty #95

Open filipleifer opened 7 years ago

filipleifer commented 7 years ago

Hi,

I have a problem with empty PNG screenshot files. File is created but there is no content. It happens sometimes but I dont know what is the reason.

My protractor config is:

var waiting = function (rootSelector, callback) { var el = document.querySelector(rootSelector); var $timeout = angular.element(el).injector().get('$timeout');
$timeout(callback, 0); };

//Require var config = require('./sessionConfig.json'); var HtmlScreenshotReporter = require('protractor-jasmine2-screenshot-reporter');

var reporter = new HtmlScreenshotReporter({ dest: 'Report', filename: 'Report.html', reportOnlyFailedSpecs: false, captureOnlyFailedSpecs: false, cleanDestination: false
});

exports.config = { seleniumAddress: config.seleniumAddress, seleniumSessionId: config.seleniumSessionId, jasmineNodeOpts: { onComplete: null, isVerbose: false, showColors: true, includeStackTrace: true, defaultTimeoutInterval: 10 120 1000 //timeout_in_millis },

beforeLaunch: function () {
    return new Promise(function (resolve) {
        reporter.beforeLaunch(resolve);
    });
},

onPrepare: function () {
    jasmine.getEnv().addReporter(reporter);
},

afterLaunch: function (exitCode) {
    return new Promise(function (resolve) {
        reporter.afterLaunch(resolve.bind(this, exitCode));
    });
},

getPageTimeout: 120000,        

framework: 'jasmine',

specs: ['*spec.js'],

plugins: [{
    inline: {
        waitForPromise: function() { 
            return browser.executeAsyncScript(waiting, browser.rootEl);
        }
    }
}]

};

anjunatl commented 7 years ago

When you say there's no content, are they 0 byte files or are they just white or both? (I've seen the white screenshots before but I'm not sure of their filesize.)

arrow-dev commented 7 years ago

I'm experiencing this issue, when running tests locally about half the screenshots are blank, seems to be taking the shot in between tests maybe? When running tests through selenium grid I still get this happening but only 5% of the time rather than 50%. If I run the specs over again it's sometimes different ones that are blank, seems like a race condition or something? I don't have anything like afterEach destroying the page either.

sdgtseleniumautomation commented 6 years ago

@anjunatl Hello Anjunatl, I am facing this issue. I am getting a png file but of o bytes. My code is: var HtmlReporter = require('protractor-jasmine2-html-reporter');

var reporter = new HtmlReporter({
dest: 'protractor-reports',
filename: 'protractor-report.html',

// screenshotsFolder: 'F:\Screeshots' });

exports.config = 
{
directconnect: true,
capabilities: {'browserName': 'chrome'},
framework: 'jasmine',
specs: ['example.js'],
jasmineNodeOpts: {
defaultTimeoutInterval: 300000
},
onPrepare: function() {
//Add a screenshot reporter and store screenshots to `/tmp/screenshots`:
      jasmine.getEnv().addReporter(reporter);

  }
  }

Can you please let me know whats wrong as I am very new to this.

myfashionhub commented 6 years ago

I seem to experience a similar problem. The screenshots are always a blank white screen (5KB).

const configureReporters = (screenshotPath, resultPath) => {
    const HtmlScreenshotReporter = require('protractor-jasmine2-screenshot-reporter');
    const screenshotReporter = new HtmlScreenshotReporter({
        dest: screenshotPath,
        captureOnlyFailedSpecs: true,
        cleanDestination: false
    });
    screenshotReporter.beforeLaunch(() => {});
};

const onPrepare = () => {
    configureReporters(
        exports.config.SCREENSHOTS_PATH, exports.config.RESULTS_PATH
    );
};
codehunter13 commented 5 years ago

any progress? :)

AbigailParrales commented 4 years ago

Same issue here, in my test I take multiple consecutive screenshots but the second screenshot comes empty more than 50% of the times. Is it a race condition?