3

I need to get the job ID / session ID from a protractor run into a file so I can create links to screenshots / videos at Saucelabs . Is there a correct way to do this?

One approach I'm looking at is to get the session ID from the browser object then pass to a custom reporter that writes it to a file:

// protractor.conf.js
onPrepare: function () {

    var sessionIdP = q.defer();

    browser.getSession().then(function(session) {
        sessionIdP.resolve(session.getId());
    });

    jasmine.getEnv().addReporter(new SessionIdWriter({
        sessionId: sessionIdP
    });
}

Should work but can this be done more cleanly?

I'm aware that Saucelabs offers a REST api that can return the latest job ID, but this presents a race condition with other users of the account. Besides the ID is known locally so a call shouldn't be needed.

tariksbl
  • 1,037
  • 6
  • 20

1 Answers1

1

I think what you are looking for are build: 'some build number' and name: 'my awesome webpage' properties in the capabilities section of your config file. these parameters will be pass through to your SL account and show up in the test run table

more info available https://docs.saucelabs.com/reference/test-configuration/#job-annotation

Chris Matheson
  • 328
  • 1
  • 7
  • The SL sessionId is different from the build number & name; but as a side note, thanks for the `name: awesome webpage` tip, the "Untitled" on the SL results page was making my eyes bleed. – tariksbl Feb 27 '15 at 15:35