I have a question about TestCafe usage. I have a script (fixture) with two tests inside. If the first test runs the URL and if not logged in, the script will log into the site.
BUT: the second test always logs in too. It looks like Testcafe does not recognize the cookies done in a fixture. What is the string inside the fixture or runner, to keep the set cookies?
import { Selector } from 'testcafe';
fixture `Ordner erstellen`
.page `xxxx`
.before(async ctx => {
ctx.clLogin = `xxxx`;
ctx.clPassword = `xxx`;
});
test('Create and Delete Folder1', async t => {
const testfolder = Selector('.np-folder-name[title="19233456"]')
await t
.typeText(Selector('#email'), t.fixtureCtx.clLogin, {
caretPos: 0
})
.typeText(Selector('#password'), t.fixtureCtx.clPassword, {
caretPos: 0
})
.click(Selector('span').withText('Login'))
.click(Selector('.np-top-section-tab.folder'))
await t
.wait(2000)
.expect(testfolder.withText('19233456').exists).notOk()
test('Create and Delete Folder2', async t => {
const testfolder = Selector('.np-folder-name[title="19233456"]')
await t
.typeText(Selector('#email'), t.fixtureCtx.clLogin, {
caretPos: 0
})
.typeText(Selector('#password'), t.fixtureCtx.clPassword, {
caretPos: 0
})
.click(Selector('span').withText('Login'))
.click(Selector('.np-top-section-tab.folder'))
await t
.wait(2000)
.expect(testfolder.withText('19233456').exists).notOk()
I also tried with the role concept from testcafe. But this is also not working well.
import { Selector, Role } from 'testcafe';
const admin = Role('https://bc3-channel.cliplister.com/', async t => {
await t
.typeText(Selector('#email'), `xxx`, {
caretPos: 0
})
.typeText(Selector('#password'), `xxx`, {
caretPos: 0
})
.click(Selector('span').withText('Login'))
});
fixture `Ordner erstellen`
.page `xxx`
test('Create and Delete Folder', async t => {
const testfolder = Selector('.np-folder-name[title="19233456"]')
await t
.useRole(admin)
.navigateTo('xxx')
.click(Selector('.np-top-section-tab.folder'))
});
test('Create and Delete Folder2', async t => {
const testfolder = Selector('.np-folder-name[title="19233456"]')
await t
.navigateTo('xxx')
.click(Selector('.np-top-section-tab.folder'))
await t
.wait(2000)
.expect(testfolder.withText('19233456').exists).notOk()
});