Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pathBuilder is not getting browser capabilities #4

Closed
mlison opened this issue Mar 3, 2015 · 16 comments
Closed

pathBuilder is not getting browser capabilities #4

mlison opened this issue Mar 3, 2015 · 16 comments

Comments

@mlison
Copy link
Owner

mlison commented Mar 3, 2015

pathBuilder in specDone method doesn't get browser capabilities passed to it.

https://github.com/mlison/protractor-jasmine2-screenshot-reporter/blob/master/index.js#L143

(same applies for metadataBuilder)

@bryanlb
Copy link

bryanlb commented Mar 20, 2015

+1

@mlison
Copy link
Owner Author

mlison commented Mar 25, 2015

There probably won't be any good / proper solutions until this is resolved: angular/protractor#1938

@eolognt
Copy link

eolognt commented May 4, 2015

Same here 👍

@flaviomeira
Copy link

+1

@Priyapanch
Copy link

Same issue

@NickLargen
Copy link

What is the issue that prompted the save filename before making a screenshot to avoid promise trouble commit? pathBuilder worked correctly for me with that change reverted.

@haugthom
Copy link

+1

@devmao
Copy link

devmao commented Oct 1, 2015

- file = opts.pathBuilder(spec, suites);

  •   file = opts.pathBuilder(spec, suites, spec._capabilities);
    

@michaschwab
Copy link

@devmao That didn't work for me, as spec doesn't seem to have that attribute - at least for me.

Thanks @NickLargen - undoing those changes fixes it for me, too.

@devmao
Copy link

devmao commented Oct 2, 2015

@michaschwab Which version of protractor are you using?
I tested it only with 2.4.0 and jasmine 2.3.2

@bvarga
Copy link

bvarga commented Oct 8, 2015

another workaround:

onPrepare: function() {
    browser.getCapabilities().then(function (capabilities) {
      browser.capabilities = capabilities;
    });

    jasmine.getEnv().addReporter(
      new HtmlScreenshotReporter({
        dest: 'test/results/screenshots',
        filename: 'screenshots.html',
        pathBuilder: function(currentSpec) {
          return browser.capabilities.get('platform') + '/' + browser.capabilities.get('browserName') + '.' + browser.capabilities.get('version') + '/' + currentSpec.fullName;
        }
      })
    );
  },

@ammachado
Copy link

+1

@AndrewFinlay
Copy link

I've had a look at this and think that this issue may be getting a little confused. Both the original method and @bvarga 's method of getting browser capabilities into the pathBuilder seem to work fine.

The problem that the original modification is trying to solve is that sometimes screenshots aren't captured if the failing test is the last spec. This seems to be due to something deeper in the Protractor stack, that fails to wait for the async finish of specDone. After running a few tests I've found that none of the changes here prevent that.

Why not go back to the original implementation to restore the browser.capability support, then as a workaround set your last spec to:

   it('This empty spec is a hack fix for Jasmine Reporters bug.', function() {});

or from the linked thread, add this to a containing suite

afterAll(function(done){
    process.nextTick(done);
});

@bmsoko
Copy link

bmsoko commented Dec 11, 2015

Can you please share what's the work around with this?

Thanks!!

@mlison
Copy link
Owner Author

mlison commented Dec 22, 2015

closed by #29

@mlison mlison closed this as completed Dec 22, 2015
@kummerer94
Copy link

I'm using Protractor 3.1 and the 0.3.0 version of protractor-jasmine-2-screenshot-reporter and still see this problem.

[INFO] [firefox #2] T:/codebase/code/ui/node_modules/protractor/node_modules/selenium-webdriver/lib/goog/../webdriver/promise.js:1337
[INFO] [firefox #2]       return callbackFn(this.value_);
[INFO] [firefox #2]              ^
[INFO] [firefox #2] TypeError: Cannot read property 'getCapabilities' of undefined
[INFO] [firefox #2]     at T:\codebase\code\ui\node_modules\protractor\node_modules\selenium-webdriver\lib\webdriver\webdriver.js:432:19
[INFO] [firefox #2]     at promise.Promise.goog.defineClass.invokeCallback_ (T:/codebase/code/ui/node_modules/protractor/node_modules/selenium-webdriver/lib/goog/../webdriver/promise.js:1337:14)
[INFO] [firefox #2]     at promise.ControlFlow.goog.defineClass.goog.defineClass.abort_.error.executeNext_.execute_ (T:/codebase/code/ui/node_modules/protractor/node_modules/selenium-webdriver/lib/goog/../webdriver/promise.js:2776:14)
[INFO] [firefox #2]     at promise.ControlFlow.goog.defineClass.goog.defineClass.abort_.error.executeNext_ (T:/codebase/code/ui/node_modules/protractor/node_modules/selenium-webdriver/lib/goog/../webdriver/promise.js:2758:21)
[INFO] [firefox #2]     at goog.async.run.processWorkQueue (T:\codebase\code\ui\node_modules\protractor\node_modules\selenium-webdriver\lib\goog\async\run.js:124:15)
[INFO] [firefox #2]     at process._tickCallback (node.js:368:9)

Does anyone know a fix for this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests