I want to generate two separate report for a single test case. For that, I am using browser.getCapabitities
method in the test by which I am getting the browser name and version.
Now, when I use this variable at the end of the spec description, the value is undefined
. The browserNameforSpec
is getting value before describe. Only when I use this value at the end of the spec, it shows undefined. I am not able to get the reason why this happens. Is there any way to change the name of this spec description before test started.
My code is
let capsPromise = browser.getCapabilities();
let browserNameforSpec;
capsPromise.then(function(caps) {
console.log(caps);
let browserName = caps.get('browserName');
let browserVersion = caps.get('version');
browserNameforSpec = browserName + '-' + browserVersion + '-';
console.log(browserNameforSpec);
});
describe( '0030 Test for login' + browserNameforSpec, function () { // this.browserNameforSpec value is undefined
// 1.
it('Navigate to the login page', async () => {
await navigate.to.the(loginPage);
});
// 2
it('Click onto language button', async() => {
await click.onto(languageButton);
await expect(languageDropdown.isDisplayed());
});
// 3
it('English Language is selected', async() => {
await click.onto(englishLanguage);
await expect(languageButton.getText()).toBe('English');
});
// 4.
it('Correct user name is written into email field', async() => {
await usernameField.click();
await enter(correctUsername, into(usernameField));
});
// 5.
it('Correct password is written into password field', async() => {
await passwordField.click().then(function () {
passwordField.clear();
enter(correctPassword, into(passwordField));
})
});
// 6.
it('Login button is clicked and home page is opened', async() => {
await click.onto(loginButton);
});
});