** First problem/question:**
I defined 2 roles in a separate file (/Support/utilities) :
import channelsPage from '..'
import config from '../Config/config';
import {Role} from 'testcafe';
import loginPage from '..';
let l1 = require('../support/global').log[1];
let l0 = require('../support/global').log[0];
const SuperUser = Role(config.baseUrl, async t => {
//Log in as superuser
await loginPage.logIn(l1.username, l1.password)
//Check if proper site opened
if (await loginPage.keycloakLoginError.exists) {
await loginPage.logIn(l1.username, l1.password)
}
else {
await t.expect(channelsPage.lineupsAndPackages.exists).ok();
await t.expect(channelsPage.createDropUp.exists).ok();
}
})
const NormalUser = Role(config.baseUrl, async t => {
//Log in as superuser
await loginPage.logIn(l0.username, l0.password)
//Check if proper site opened
if (await loginPage.keycloakLoginError.exists) {
await loginPage.logIn(l1.username, l1.password)
}
else {
await t.expect(channelsPage.lineupsAndPackages.exists).ok();
await t.expect(channelsPage.createDropUp.exists).ok();
}
})
module.export ={
SuperUser: SuperUser,
NormalUser: NormalUser
}
and then used one of the defined role: NormalUser in testscript (another file)
import config from './Config/config';
import NormalUser from './Support/utilities';
fixture`SanityTests`
.beforeEach(async t => {
await t.maximizeWindow()
})
.page`${config.baseUrl}`;
test('Search', async t => {
await t.maximizeWindow();
//Log in
await t.useRole(NormalUser.NormalUser)
});
The test failed because: " The "role" argument is expected to be a Role instance, but it was undefined."
When I have these in one file - the test passed, so the problem must be in wrong defined role (how to do it correctly?)
II Second problem/question
When I am creating the Role constructor: Role( URL, func( t ) [, options] ) I must point the URL of the login page and then when I create test into fixtures I must configure the fixture - specifying the start webpage,
fixture My fixture
.page http://www.example.com/
;
so this page is a double loading...
How to avoid it?
Aucun commentaire:
Enregistrer un commentaire