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

Not able to create a dynamic reporting path(which will include browser name ,Date time etc) for multi-capabilities #26

Closed
Tehaseen opened this issue Nov 28, 2017 · 3 comments

Comments

@Tehaseen
Copy link

Observation:
In the onPrepare() function when we define path for report in the baseDirectory , i am not able get the value of browser name . Refer the below code

onPrepare: function() {
browser.getCapabilities().then(function(caps){
console.log('THe browser name '+ browser.browserName);
browser.browserName= caps.get('browserName');
});
jasmine.getEnv().addReporter(new HtmlReporter({
baseDirectory: '../../../../../../Test/'+browser.browserName,
pathBuilder: function pathBuilder(spec, descriptions, results) {
// Return '/' as path for screenshots:
// Example: 'firefox/list-should work'.
return path.join( descriptions) ;},
screenshotsSubfolder: 'ScreenShots',
jsonsSubfolder: 'Jsons',
docTitle: 'Report',
docName: 'Report.html',
preserveDirectory: false
}).getJasmine2Reporter());
}

We require to create a dynamic path because multicapabilities launches on different browser . So different browser will require different path .

In the above code ,
"browser.browserName" in console log is returning a promise .
"browser.browserName" in the baseDirectory is returning a string "undefined".

tried using path builder property , but this property builds path only for screen shot .

Expected Result :
Generate a dynamic reporting path based on browser name
So that when we use this plugin for multi-capabilities , different browser will have different report

Thanks in Advance :)

@Tehaseen Tehaseen changed the title Cannot create a dynamic reporting path(which will include browser name ,Date time etc) for multi-capabilities Not able create a dynamic reporting path(which will include browser name ,Date time etc) for multi-capabilities Nov 28, 2017
@Tehaseen Tehaseen changed the title Not able create a dynamic reporting path(which will include browser name ,Date time etc) for multi-capabilities Not able to create a dynamic reporting path(which will include browser name ,Date time etc) for multi-capabilities Nov 28, 2017
@miller45
Copy link
Collaborator

Maybe you can find a solution here: angular/protractor#1938
scroll to the bottom there...

@Evilweed
Copy link
Owner

Evilweed commented Dec 4, 2017

browser.browserName = caps.get('browserName'); returns a promise so in order to use this information You need to unwrap it...

browser.browserName = caps.get('browserName');

browser.browserName.then((name) => {
    jasmine.getEnv().addReporter(new HtmlReporter({
    baseDirectory: '../../../../../../Test/'+name,
    ...
    }).getJasmine2Reporter());
})

@Evilweed Evilweed closed this as completed Dec 4, 2017
@Tehaseen
Copy link
Author

Hi Evilweed,
Thanks for the reply , but when i try to unwrap promise i am getting the below error.
"TypeError: browser.browserName.then is not a function"

Please find the below onPrepare function

_onPrepare: function() {
browser.getCapabilities().then(function(caps){
console.log('THe browser name '+ browser.browserName);
browser.browserName= caps.get('browserName');

    browser.browserName.then(function(name) {
    jasmine.getEnv().addReporter(new HtmlReporter({
    baseDirectory: '../../../../../../Test/'+name,
    pathBuilder: function pathBuilder(spec, descriptions, results) {
    // Return '/' as path for screenshots:
    // Example: 'firefox/list-should work'.
    return path.join( descriptions) ;},
    screenshotsSubfolder: 'ScreenShots',
    jsonsSubfolder: 'Jsons',
    docTitle: 'Report',
    docName: 'Report.html',
    preserveDirectory: false
    }).getJasmine2Reporter());
  });
});
    }_

Expected Result: Generate a dynamic reporting path based on browser name
So that when we use this plugin for multi-capabilities , different browser will have different report

Many Thanks in Advance

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

3 participants