Giter Site home page Giter Site logo

mlison / protractor-jasmine2-screenshot-reporter Goto Github PK

View Code? Open in Web Editor NEW
81.0 81.0 79.0 149 KB

Protractor screenshot reporter for Jasmine2

Home Page: https://www.npmjs.com/package/protractor-jasmine2-screenshot-reporter

License: MIT License

JavaScript 100.00%

protractor-jasmine2-screenshot-reporter's People

Contributors

blancheyap avatar brandenbyers avatar chrismikehogan avatar fourcube avatar jvanoosterom avatar kylelilly avatar mlison avatar nickwerline avatar nicole-ashley avatar ruhley avatar tsachis avatar yevgenys avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

protractor-jasmine2-screenshot-reporter's Issues

dest directory not created

In the latest version 0.3.1 the issue #10 is not solved for me. As it is a closed issue I'm cross-posting my investigation here.

I've tracked it down to beforeLaunch and thus cleanDestination() not being called. How are these functions supposed to be called? I'd imagine they should be called from the jasmineStarted hook no?

Is this a jasmine misbehavior?

Screenshot for last 'it' is not taken

For last 'it' the screenshot is not taken:

The below is my config setting
onPrepare: function() {
jasmine.getEnv().addReporter(new HtmlScreenshotReporter({dest: 'target/screenshots',filename: 'my-report.html'}));
}

Code sample:
describe('super calculator actions' , function(){

var CalculatorPage = require('./Calc_Page.js');

it('addtion',function(){
CalculatorPage.navigate();
CalculatorPage.EnterFirst(3);
CalculatorPage.SelectOperator("ADDITION");
CalculatorPage.EnterSecond(4);
CalculatorPage.ClickGo();
var actualVal = element(by.binding('latest')).getText();
expect(actualVal).toEqual('7');
});
it('verify history',function(){
var eleHistory = element.all(by.repeater('result in memory'));
expect(eleHistory.get(0).getText()).toContain('3 + 4 7');

});
});

for last one 'verify history' the screen shot is not taken. any inputs for this?

Failed to get screenshot for some of the specs

It was working fine in my windows machine and screwed up with this error after switching to Mac.

.Failed to get screenshot: UnknownError: unknown error: cannot take screenshot
from unknown error: Failed to capture tab: unknown error
JavaScript stack:
Error: Failed to capture tab: unknown error
at checkForExtensionError (chrome-extension://aapnijgdinlhnhlmodcfapnahmbfebeb/background.js:14:17)
at Object.callback (chrome-extension://aapnijgdinlhnhlmodcfapnahmbfebeb/background.js:37:5)
at safeCallbackApply (extensions::sendRequest:21:15)
at handleResponse (extensions::sendRequest:72:7)
(Session info: chrome=45.0.2454.93)
(Driver info: chromedriver=2.15.322455 (ae8db840dac8d0c453355d3d922c91adfb61df8f),platform=Mac OS X 10.10.5 x86_64)

Not getting screenshot when in Ubuntu

Hi,

I'm trying out protractor reporting tools and I successfully got a report with screenshots using this when I was in Windows but using the same specs and config files in Ubuntu, I'm only able to get the report with incorrect data and no screenshot was generated.

Could you please advise. Thank you.

Last 'it' not producing a screenshot

When creating a test the last 'it' will not produce a link to the produced screenshot. I have tested this by changing the number used:

  1. When one 'it's are used - it will not produce a link.

  2. When two 'it's are used - the second will not produce a link.

  3. When three 'it's are used - the third will not produce a link.

I have provided screenshots which shows each of these scenarios. I have managed to workaround this issue by creating a 'dummy' it at the end of the test file.

image

Problems on windows

There are mainly two problems on windows machines if you are running protractor with this reporter:

  1. If you have some more and longer descripted it cases they result in a file name that is too long. You cannot open it in the browser (if you open the report.html and click on the filename)
  2. If the it case has some special characters (e.g. doubleqoutes) the screenshot is not saved anymore

No longer creates dest directory

Having upgraded to 0.30 my dest directory is no longer being created automatically. The first time the reporter attempts to access it fails. If I create the dest directory manually the reporter works fine.

Protractor Config:

jasmine.getEnv().addReporter(
new HtmlScreenshotReporter({
dest: 'target/screenshots/',
cleanDestination: true,
filename: 'E2E-test-report.html',
ignoreSkippedSpecs: true,
captureOnlyFailedSpecs: true,
showSummary: true
})
);

Npm config :

"protractor": "^3.0.0",
"protractor-jasmine2-screenshot-reporter": "^0.3.0",
"jasmine-core": "^2.4.1",
"jasmine-reporters": "^2.1.1",
"selenium-webdriver": "^2.48.2",
"webdriver-manager": "^8.0.0"

If I revert to 0.20 and do nothing else, the problem goes away.

Error :
[firefox #2] .Error: ENOENT: no such file or directory, open 'target/screenshots/E2E-test-report.html'
[firefox #2] at Error (native)
[firefox #2] at Object.fs.openSync (fs.js:549:18)
[firefox #2] at Object.fs.writeFileSync (fs.js:1155:15)
[firefox #2] at Object.fs.appendFileSync (fs.js:1203:6)
[firefox #2] at Jasmine2ScreenShotReporter.jasmineDone (/mnt/storage/dev_workspace_performance/workspace/Projects/shoal-platform/shoal-client/node_modules/protractor-jasmine2-screenshot-reporter/index.js:482:10)
[firefox #2] at dispatch (/mnt/storage/dev_workspace_performance/workspace/Projects/shoal-platform/shoal-client/node_modules/jasmine/node_modules/jasmine-core/lib/jasmine-core/jasmine.js:1869:28)
[firefox #2] at /mnt/storage/dev_workspace_performance/workspace/Projects/shoal-platform/shoal-client/node_modules/jasmine/node_modules/jasmine-core/lib/jasmine-core/jasmine.js:1852:11
[firefox #2] at QueueRunner.clearStack (/mnt/storage/dev_workspace_performance/workspace/Projects/shoal-platform/shoal-client/node_modules/jasmine/node_modules/jasmine-core/lib/jasmine-core/jasmine.js:605:9)
[firefox #2] at QueueRunner.run (/mnt/storage/dev_workspace_performance/workspace/Projects/shoal-platform/shoal-client/node_modules/jasmine/node_modules/jasmine-core/lib/jasmine-core/jasmine.js:1784:12)
[firefox #2] at /mnt/storage/dev_workspace_performance/workspace/Projects/shoal-platform/shoal-client/node_modules/jasmine/node_modules/jasmine-core/lib/jasmine-core/jasmine.js:1801:16

Ignore Skipped Specs Doesn't Respect Use of "fit" / "fdescribe"

Issue:
If I set "ignoreSkippedSpecs" to "true" and then, in my spec files, use "fit" or "fdescribe" to only run a single test/block of tests, the screenshot reporter still creates screenshots for all of the tests in my suite, even though only a fraction of those are being executed.

For example, I have a suite with 82 tests. I only run 3 of those, by marking the desired tests with "fit". Protractor only executes the 3 marked tests, skipping everything else, but the screenshot reporter puts 82 screenshots in the destination directory, and creates a report that references all 82 tests as though they had all been run. Most of these screenshots are not at all appropriate to the tests they're mapped to, because, of course, those tests weren't actually executed.

I'm guessing this is because the "ignore" logic is looking specifically for "xit" and "xdescribe" to decide if a test is being skipped. When I use "fit" to run a single test, I don't make any changes to the other tests in the suite - Protractor skips them at runtime.

Here's my config for the reporter:

var HtmlReporter = new HtmlScreenshotReporter({
  dest: "/tmp",         
  filename: "my-report.html",                  
  ignoreSkippedSpecs: true,                    
  reportOnlyFailedSpecs: false,                
  captureOnlyFailedSpecs: false                
});                                            
jasmine.getEnv().addReporter(HtmlReporter);    

Environment:
Protractor v3.3.0
Jasmine2 v2.4.1
Node v6.3.0
npm v3.10.5
protractor-jasmine2-screenshot-reporter v0.3.2

Steps to Reproduce:

  1. install and configure protractor-jasmine2-screenshot-reporter
  2. in protractor.conf.js, set the ignoreSkippedSpecs flag to "true" for this plugin
  3. in your spec files, mark one or more tests as focus tests by prepending "f" to an "it" or "describe" block. ("fit" or "fdescribe")
  4. run protractor
  5. after execution is complete, check the screenshots and report generated by this reporter.

Expected:
It would be nice if the "ignoreSkippedSpecs" option tracked which test cases Protractor is actually executing at runtime, so that using either "xit" (to exclude one test) or "fit" (to exclude EVERYTHING BUT one test) would result in only the tests executed being run.

Perhaps, if necessary, a separate flag could be made to track use of focus tests ("fit") and leave the ignoreSkippedSpecs flag as-is.

Client Logging Data Available in Report

I'm not sure if this is the right place to put this, and more over, I am unsure if this is something that belongs within the scope of this project, but it is something I would find useful and something I am sure others would find useful as well.

I would like to be able to see the narrative of steps taken in a particular test case, similar to the way RobotFramework reports show it, I have looked briefly into the way you get data in your reporter. Specifically using Jasmine's baked in result object that has access only to the following properties.

result = {
      id: this.id,
      description: this.description,
      fullName: this.getFullName(),
      failedExpectations: [],
      passedExpectations: [],
      pendingReason: ''
    }; 

This is useful, but for selenium reporting there is a lot more involved than simple expectations i.e. A shit ton of navigation and configuration. If you added a "client" logger in the capabilities object you have access to logs that look like:

Executing: [add cookie: hp=990f61ff-6005-4522-8b97-080773dedd2c; path=/])
Done: [add cookie: hp=990f61ff-6005-4522-8b97-080773dedd2c; path=/]
Executing: [set window size])
Done: [set window size]

What I would like is a way to have access to loggers that were declared in the capabilities object.

I have jimmy rigged your framework to send my desired data to your reporter, but I was wondering what your thoughts on this were and if you had any plans on going in this direction.

Error is thrown after upgrading to 0.3.2

No such file or directory error is thrown after upgrading from 0.3.1 to 0.3.2 without updating protractor config file/ test spec files.

Error: ENOENT: no such file or directory, open '${test-project}/output/ui-test/index.html'
at Error (native)
at Object.fs.openSync (fs.js:549:18)
at Object.fs.writeFileSync (fs.js:1156:15)
at Object.fs.appendFileSync (fs.js:1204:6)
at Jasmine2ScreenShotReporter.jasmineDone (${env-path}/node_modules/protractor-jasmine2-screenshot-reporter/index.js:500:10)
at dispatch (/usr/local/lib/node_modules/protractor/node_modules/jasmine/node_modules/jasmine-core/lib/jasmine-core/jasmine.js:1966:28)
at ReportDispatcher.jasmineDone (/usr/local/lib/node_modules/protractor/node_modules/jasmine/node_modules/jasmine-core/lib/jasmine-core/jasmine.js:1949:11)
at /usr/local/lib/node_modules/protractor/node_modules/jasmine/node_modules/jasmine-core/lib/jasmine-core/jasmine.js:758:18
at QueueRunner.clearStack (/usr/local/lib/node_modules/protractor/node_modules/jasmine/node_modules/jasmine-core/lib/jasmine-core/jasmine.js:660:9)
at QueueRunner.run (/usr/local/lib/node_modules/protractor/node_modules/jasmine/node_modules/jasmine-core/lib/jasmine-core/jasmine.js:1881:12)
18:59:00

Report file not found

This error happens when running a test suite that only has a single test. As soon as another it block is added (can be even empty), this issue no longer exists.

Error: ENOENT: no such file or directory, open 'C:\...\e2e\reports\10-Mar-2016-13h-10m\report.html' at Error (native) at Object.fs.openSync (fs.js:584:18) at Object.fs.writeFileSync (fs.js:1224:33) at Object.fs.appendFileSync (fs.js:1283:6) at Jasmine2ScreenShotReporter.jasmineDone (C:\...\node_modules\protractor-jasmine2-screenshot-reporter\index.js:482:10) at dispatch (C:\Users\...\AppData\Roaming\npm\node_modules\protractor\node_modules\jasmine-core\lib\jasmine-core\jasmine.js:1966:28) at ReportDispatcher.jasmineDone (C:\Users\...\AppData\Roaming\npm\node_modules\protractor\node_modules\jasmine-core\lib\jasmine-core\jasmine.js:1949:11) at C:\Users\...\AppData\Roaming\npm\node_modules\protractor\node_modules\jasmine-core\lib\jasmine-core\jasmine.js:758:18 at QueueRunner.clearStack (C:\Users\...\AppData\Roaming\npm\node_modules\protractor\node_modules\jasmine-core\lib\jasmine-core\jasmine.js:660:9) at QueueRunner.run (C:\Users\...\AppData\Roaming\npm\node_modules\protractor\node_modules\jasmine-core\lib\jasmine-core\jasmine.js:1881:12) [launcher] Process exited with error code 1

Report style format doesn't show summary and table

Hi,

I have the report working however it shows up as a list with the links to the screenshot and not the table and summary at the bottom. Is there something else i need to do or add to make sure it looks exactly as the examples.
screen shot 2015-08-12 at 3 01 31 pm

Problem with screenshot for last step in suite.

Hello,
Everything works fine, I see all steps in HTML report, but when I press on last step (when screenshot should open), it doesn't exist - screenshot for last step in my suite is not saving, no idea why.

Feel free to check it out by running this repo with Protractor:
https://github.com/drptbl/protractortesting/tree/lastscreenshotmissing

I'm talking about this step:
"✓should close cookie frame after acceptation (12 s)" - screenshot is missing.

Any ideas how to fix?
Tried wait and sleep after last step without success.

Generating browser-wise report.

Is there any way where we can generate html report browser-wise. I have selenium-grid environment set up and we are using protractor-jasmine2-screenshot-reporter to generate reports. Reporter successfully generate a single html report for all specs on for all test executed on all browsers. It would be good if there is also an option to generate different browser-wise reports.

Can't load external css

Here is my protractor configuration file :

var HtmlScreenshotReporter = require('protractor-jasmine2-screenshot-reporter'); exports.config = { framework: 'jasmine2', seleniumAddress: 'http://localhost:4444/wd/hub', specs: ['spec.js'], capabilities: { browserName: 'chrome' }, onPrepare: function () { jasmine.getEnv().addReporter(new HtmlScreenshotReporter({ dest: 'target/screenshots_chrome', filename: 'my-report.html', userCss: 'my-reporter.css' })); browser.driver.manage().window().maximize(); jasmineNodeOpts: { showColors: true; defaultTimeoutInterval: 5000; }; browser.manage().timeouts().pageLoadTimeout(5000); browser.manage().timeouts().implicitlyWait(5000); allScriptsTimeout: 5000; getPageTimeout: 5000; }, };

The problem is that the reporter is not using 'my-reporter.css' in any way. None of the changes i made to the css file are reflected in the report.

No screenshots on bail

If you bail ("quit") the test runner, no screenshots are taken (or no screenshots are saved).

The screenshots only appear to be saved when all the specs have finished running. I understand why this makes sense for the html report, but I think it is bad for the screenshots.

For example: say you have a very large suite of tests, you see one failure on the screen. You kill the tests. You go to see the screenshot to see what happened. No screenshot because the reporter hasn't finished up and move the screenshots into the directory yet.

HTML reporter does not play nice when running in parallel

When I run N test files in M parallel processes, such that M < N, then report.html will only show the last M test file results.

For example (where N = 3, and M = 2):

    // in protractor.conf.js (partial)
    specs: [
        'spec/one.js',
        'spec/two.js'
        'spec/three.js'
    ],
    capabilities: {
        browserName: 'chrome',
        shardTestFiles: true, // run specs in parallel
        maxInstances: 2 // max number of parallel specs
    },
    //....
    onPrepare(function() {
        jasmine.getEnv().addReporter(new HtmlScreenshotReporter({
            dest: 'report/ptor',
            pathBuilder: function(currentSpec) {
                return 'screenshots/' + currentSpec.fullName;
            }
        }));  
    }),
    // ....

Will result in a report that, assuming two.js and three.js finish after one.js, only shows two.js and three.js results.

This appears to be part of why this happens: https://github.com/mlison/protractor-jasmine2-screenshot-reporter/blob/master/index.js#L246-L256 (note that this code just recently change, though it appears to behave similarly to the fs.unlink that used to be around).

Im not totally certain what the best way to go about fixing this is. Locally, I have simply 86'd the cleanup that is done at start, and have some separate clean up scripts I run when needed, but that might not be the right way.

Should the clean up step linked up be toggleable? Have any other folks encountered this problem and found a more elegant solution?

Howto generate screenshots from multiple browsers?

Is it possible to generate a screenshot from each browser forkedInstance generated in the spec? At this moment I only see one screenshots of the browser, but not from the forked instances.
I have tests that fire up 6 browsers. I need to create screenshots from all of them when the test fails.

Adding stacktrace to the HTML report

Is there a reason why the stack trace is not added to the report? I find it handy to have the stack trace available. For example if you have a spec with more expectations than one it it nice to see which line in your file throws the error. This is found in the stack trace.

Maybe the reason template can be expanded to display stack trace onClick, something like:

    var reasonsTemplate = _.template(
      '<ul>' +
          '<% _.forEach(reasons, function(reason) { %>' +
              '<li><%- reason.message %> - <a href="toggleDisplay()">Stacktrace</a></li>' +
              '<div id="stacktrace" style="display: none;"><%- reason.stack %></div>' +
          '<% }); %>' +
      '</ul>'
    );

Screenshots not being taken.

Hello.

This creates a folder for me. and puts the html report in there.

but there are no .png files in the folder.

the report has hyperlinks that go to nowhere.

there are no errors in the console.

any ideas?

var HtmlScreenshotReporter = require('protractor-jasmine2-screenshot-reporter');

jasmine.getEnv().addReporter(
  new HtmlScreenshotReporter({
    dest: 'target/screenshots',
    filename: 'my-report.html'
  })
);

require('string.prototype.startsWith')

You capitalized the startsWith, should be startswith lowercase!

> require('string.prototype.startsWith');
Error: Cannot find module 'string.prototype.startsWith'
    at Function.Module._resolveFilename (module.js:338:15)
    at Function.Module._load (module.js:280:25)
    at Module.require (module.js:364:17)
    at require (module.js:380:17)
    at repl:1:1
    at REPLServer.self.eval (repl.js:110:21)
    at repl.js:249:20
    at REPLServer.self.eval (repl.js:122:7)
    at Interface.<anonymous> (repl.js:239:12)
    at Interface.emit (events.js:95:17)

fix indentation in readme

Not a big thing, but pretty annoying. Can you please remove the 3 spaces in the first column fo code and replace them with 2?

Thaaanks :)

Protractor exits before screenshot is taken....

In this method in index.js#ln302, i can see browser.takeScreenshot method is called (i can see logs printed till this point).
But before the returned promise gets resolved and then callback is called, the process exits. And hence, the screenshot is not stored anywhere.

   this.specDone = function(spec) {
       ---------
       console.log("[sk]going to call the browser takeScreenshot.....") //this line gets printed
        browser.takeScreenshot().then(function (png) {
            console.log("[sk]inside browser.takeScreenshot.then....")  //this line doesn't come

My report.html looks like this, without any screenshot links....
rprt

Show OS type?

Is it possible to show what operating system the test is running in? I run my tests in remote desktops and it would be nice to see which tests fail on which OS.

When using fit(), no spec is ran

When using the screenshot reporter, if one or more spec are focused (fit() instead of it()), no spec is ran by Protractor.

However, I am able to run only a focused suite with fdescribe(). But as soon as there is one focused spec, Protractor ends printing "No specs found" in the console.

I am using Protractor 2.0.0 with Jasmine 2.1.1 and protractor-jasmine2-screenshot-reporter 0.1.4.

Report is showing only the last executed test

I'm running the reporter on selenium grid, but when my suite ends, the reporter only shows the last executed test.
I also have noticed that I am getting this error on console log, on some tests: "problem trying to remove a folder:./target/reports/desktop/"

Here is my conf :
var htmlReporter = new HtmlReporter({
savePath: './target/reports/desktop/',
filePrefix: 'index.html',
takeScreenshots: true,
takeScreenshotsOnlyOnFailures: true,
captureOnlyFailedSpecs: true,
cleanDestination: false,
showSummary: false,
showConfiguration: false,
reportTitle: null,
preserveDirectory: false
});

If I run the tests locally, everything works fine.

Can you help ?
Thanks

requireJS name incorrect

Help says use " require('protractor-jasmine2-screenshot-reporter'); ",but it can't work,after I checked package.json then I adjust "require('protractor-jasmine2-screenshot-report');",I can work.

Found Issue with stack trace in html report.

Issue
Clicking on stack trace link opens stack trace details for another spec for other browser.

Steps reproducible

  1. Create a test suite with 15 to 20 specs.
  2. Code in such a way that some of specs gets fail each time test suite is executed.
  3. Execute the test suite using selenium grid environment with different browsers (I have used chrome and firefox browsers ).
  4. After completion of execution, html report will have two section. Let's consider section 1 as firefox section (i.e. it will show testing result executed in firefox) and section 2 as Chrome.
  5. Click on one of the stack trace link in Chrome section.

Actual Result
You will observe that clicking on stack trace link in chrome section will open stack details in firefox section.

Sample report
Attached is the sample report with the same scenario and behavior
tests-report.html.zip

.

Screenshot paths are getting '/' encoded

setup

jasmine.getEnv().addReporter(new HtmlScreenshotReporter({
    dest: 'report/ptor',
    pathBuilder: function(currentSpec) {
        return 'screenshots/' + currentSpec.fullName;
    }
}));

expected result
Screenshots get written into report/ptor/screenshots/*
The links in the report.html link into report/ptor/screenshots/*

actual result
Screenshots get written into report/ptor/screenshots/ (yay!)
BUT the links in the report.html link into report/ptor/screenshots%2F (bummer!)

Cannot call method 'getCapabilities' of undefined

I get the above error after running my tests. I'm not sure if it's a duplicate of #4, and I'm sorry if it is :)
I currently have two tests, and for one of them a screenshot is being generated. Full trace below.

My protractor config looks like this:

exports.config = {
  framework: 'jasmine2',
  mocks: {
    default: ['Generic/Profile'],
    dir: 'tests/mocks'
  },
  onPrepare: function() {
    var HtmlScreenshotReporter = require('protractor-jasmine2-screenshot-reporter');
    jasmine.getEnv().addReporter(new HtmlScreenshotReporter({
      dest: 'protractorScreenshots'
    }));
  },
  specs: ['tests/e2e/**/*.spec.js']
};
TypeError: Cannot call method 'getCapabilities' of undefined
    at /Users/hco/src/foobar/node_modules/selenium-webdriver/lib/webdriver/webdriver.js:430:20
    at promise.ControlFlow.runInFrame_ (/Users/hco/src/foobar/node_modules/selenium-webdriver/lib/webdriver/promise.js:1877:20)
    at promise.Callback_.goog.defineClass.notify (/Users/hco/src/foobar/node_modules/selenium-webdriver/lib/webdriver/promise.js:2464:25)
    at promise.Promise.notify_ (/Users/hco/src/foobar/node_modules/selenium-webdriver/lib/webdriver/promise.js:563:12)
    at Array.forEach (native)
    at Object.goog.array.forEach (/Users/hco/src/foobar/node_modules/selenium-webdriver/lib/goog/array/array.js:203:43)
    at promise.Promise.notifyAll_ (/Users/hco/src/foobar/node_modules/selenium-webdriver/lib/webdriver/promise.js:552:16)
    at goog.async.run.processWorkQueue [as _onTimeout] (/Users/hco/src/foobar/node_modules/selenium-webdriver/lib/goog/async/run.js:125:21)
    at Timer.listOnTimeout [as ontimeout] (timers.js:112:15)
From: Task: WebDriver.manage().timeouts().setScriptTimeout(11000)
    at [object Object].webdriver.WebDriver.schedule (/Users/hco/src/foobar/node_modules/selenium-webdriver/lib/webdriver/webdriver.js:360:15)
    at [object Object].webdriver.WebDriver.Timeouts.setScriptTimeout (/Users/hco/src/foobar/node_modules/selenium-webdriver/lib/webdriver/webdriver.js:1367:23)
    at [object Object].Runner.createBrowser (/Users/hco/src/foobar/node_modules/protractor/lib/runner.js:181:30)
    at /Users/hco/src/foobar/node_modules/protractor/lib/runner.js:257:21
    at _fulfilled (/Users/hco/src/foobar/node_modules/protractor/node_modules/q/q.js:797:54)
    at self.promiseDispatch.done (/Users/hco/src/foobar/node_modules/protractor/node_modules/q/q.js:826:30)
    at Promise.promise.promiseDispatch (/Users/hco/src/foobar/node_modules/protractor/node_modules/q/q.js:759:13)
    at /Users/hco/src/foobar/node_modules/protractor/node_modules/q/q.js:573:44
    at flush (/Users/hco/src/foobar/node_modules/protractor/node_modules/q/q.js:108:17)
    at process._tickCallback (node.js:419:13)

Protractor fails if there were no screenshots taken with captureOnlyFailedSpecs

Version: 0.3.0

Issue

Protractor run fails due to the reporter trying to create a screenshots index file when there are no screenshots taken. caputreOnlyFailedSpecs will always fail in a successful run unless the destination folder is created beforehand.

Expected behaviour

Since the normal behaviour for the reporter is to automatically create the folder, I'd expect it either not to create the file when there is nothing to report, or to create the folder before trying to write to it.

Debug info

Relevant protractor configuration

    HtmlScreenshotReporter = require 'protractor-jasmine2-screenshot-reporter'
    jasmine.getEnv().addReporter new HtmlScreenshotReporter({
      dest: 'reports/e2e/screenshots'
      filename: 'index.html'
      ignoreSkippedSpecs: true,
      reportOnlyFailedSpecs: false
      captureOnlyFailedSpecs: true
    })

Protractor output:

28-Jun-2016 10:48:58    Error: ENOENT: no such file or directory, open 'reports/e2e/screenshots/index.html'
28-Jun-2016 10:48:58        at Error (native)
28-Jun-2016 10:48:58        at Object.fs.openSync (fs.js:549:18)
28-Jun-2016 10:48:58        at Object.fs.writeFileSync (fs.js:1156:15)
28-Jun-2016 10:48:58        at Object.fs.appendFileSync (fs.js:1204:6)
28-Jun-2016 10:48:58        at Jasmine2ScreenShotReporter.jasmineDone (/path/to/project/node_modules/protractor-jasmine2-screenshot-reporter/index.js:482:10)
28-Jun-2016 10:48:58        at dispatch (/path/to/project/node_modules/jasmine-core/lib/jasmine-core/jasmine.js:1869:28)
28-Jun-2016 10:48:58        at /path/to/project/node_modules/jasmine-core/lib/jasmine-core/jasmine.js:1852:11
28-Jun-2016 10:48:58        at QueueRunner.clearStack (/path/to/project/node_modules/jasmine-core/lib/jasmine-core/jasmine.js:605:9)
28-Jun-2016 10:48:58        at QueueRunner.run (/path/to/project/node_modules/jasmine-core/lib/jasmine-core/jasmine.js:1784:12)
28-Jun-2016 10:48:58        at /path/to/project/node_modules/jasmine-core/lib/jasmine-core/jasmine.js:1801:16
28-Jun-2016 10:48:58        at /path/to/project/node_modules/jasmine-core/lib/jasmine-core/jasmine.js:1745:9
28-Jun-2016 10:48:58        at queueRunnerFactory.onComplete (/path/to/project/node_modules/jasmine-core/lib/jasmine-core/jasmine.js:2348:17)
28-Jun-2016 10:48:58        at QueueRunner.clearStack (/path/to/project/node_modules/jasmine-core/lib/jasmine-core/jasmine.js:605:9)
28-Jun-2016 10:48:58        at QueueRunner.run (/path/to/project/node_modules/jasmine-core/lib/jasmine-core/jasmine.js:1784:12)
28-Jun-2016 10:48:58        at /path/to/project/node_modules/jasmine-core/lib/jasmine-core/jasmine.js:1801:16
28-Jun-2016 10:48:58        at /path/to/project/node_modules/jasmine-core/lib/jasmine-core/jasmine.js:1745:9
28-Jun-2016 10:48:58        at queueRunnerFactory.onComplete (/path/to/project/node_modules/jasmine-core/lib/jasmine-core/jasmine.js:2348:17)
28-Jun-2016 10:48:58        at QueueRunner.clearStack (/path/to/project/node_modules/jasmine-core/lib/jasmine-core/jasmine.js:605:9)
28-Jun-2016 10:48:58        at QueueRunner.run (/path/to/project/node_modules/jasmine-core/lib/jasmine-core/jasmine.js:1784:12)
28-Jun-2016 10:48:58        at /path/to/project/node_modules/jasmine-core/lib/jasmine-core/jasmine.js:1801:16
28-Jun-2016 10:48:58        at /path/to/project/node_modules/jasmine-core/lib/jasmine-core/jasmine.js:1745:9
28-Jun-2016 10:48:58        at queueRunnerFactory.onComplete (/path/to/project/node_modules/jasmine-core/lib/jasmine-core/jasmine.js:2348:17)
28-Jun-2016 10:48:58        at QueueRunner.clearStack (/path/to/project/node_modules/jasmine-core/lib/jasmine-core/jasmine.js:605:9)
28-Jun-2016 10:48:58        at QueueRunner.run (/path/to/project/node_modules/jasmine-core/lib/jasmine-core/jasmine.js:1784:12)
28-Jun-2016 10:48:58        at /path/to/project/node_modules/jasmine-core/lib/jasmine-core/jasmine.js:1801:16
28-Jun-2016 10:48:58        at /path/to/project/node_modules/jasmine-core/lib/jasmine-core/jasmine.js:1745:9
28-Jun-2016 10:48:58        at complete (/path/to/project/node_modules/jasmine-core/lib/jasmine-core/jasmine.js:365:9)
28-Jun-2016 10:48:58        at QueueRunner.clearStack (/path/to/project/node_modules/jasmine-core/lib/jasmine-core/jasmine.js:605:9)
28-Jun-2016 10:48:58        at QueueRunner.run (/path/to/project/node_modules/jasmine-core/lib/jasmine-core/jasmine.js:1784:12)
28-Jun-2016 10:48:58        at /path/to/project/node_modules/jasmine-core/lib/jasmine-core/jasmine.js:1801:16
28-Jun-2016 10:48:58        at /path/to/project/node_modules/jasmine-core/lib/jasmine-core/jasmine.js:1745:9
28-Jun-2016 10:48:58        at /path/to/project/node_modules/jasminewd2/index.js:18:5
28-Jun-2016 10:48:58        at [object Object].promise.Promise.goog.defineClass.invokeCallback_ (/path/to/project/node_modules/selenium-webdriver/lib/goog/../webdriver/promise.js:1337:14)
28-Jun-2016 10:48:58        at [object Object].promise.ControlFlow.goog.defineClass.goog.defineClass.abort_.error.executeNext_.execute_ (/path/to/project/node_modules/selenium-webdriver/lib/goog/../webdriver/promise.js:2776:14)
28-Jun-2016 10:48:58        at [object Object].promise.ControlFlow.goog.defineClass.goog.defineClass.abort_.error.executeNext_ (/path/to/project/node_modules/selenium-webdriver/lib/goog/../webdriver/promise.js:2758:21)
28-Jun-2016 10:48:58        at goog.async.run.processWorkQueue (/path/to/project/node_modules/selenium-webdriver/lib/goog/async/run.js:124:15)
28-Jun-2016 10:48:58        at process._tickCallback (node.js:368:9)
28-Jun-2016 10:48:58    [launcher] Process exited with error code 1

Screenshot not linked

I am trying to generate a HTML report with screenshots for my Protractor tests. I am currently testing on two different browsers (Chrome and Firefox).

The plugin will not link the last screenshot but it is present in the directory.

issues jasmine2-reporter plugin

Force take screenshot at the end of the it() block

Currently, it seems like screenshot for a failed spec is taken after the afterEach() or afterAll() methods are executed. This means that if you have some clean-up in the afterEach() which opens a new page, the screenshot of this page, instead of the failed one will be taken.

Is there a way to force taking the screenshot at the end of each it() block?

Is it possible to preserve screenshots while making a new report?

I'd like to be able to have screenshots for all specs, and only overwrite the screenshot if I run that spec, so that I always have a library of the most recent screenshots for every spec.

cleanDestination = false achieves this, but also makes the report.html grow by just appending new
reports to it, rather than overwriting. So the report will get very large and cluttered over time.

cleanDestination = true means I get a new report each time, but all your screenshots are deleted if you want to run just one spec instead of the whole suite.

I managed to get things working how I wanted by replacing the call to fs.appendFile on line 336 of index.js with fs.writeFile. Seems to work as intended although I haven't looked into all the consequences yet. Maybe this could be an option in a future update?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.