Reputation: 177
I am using one condition( if-else loop) to use different URLs based on the env. I am mentioning this in fixture.beforeEach(..) and want to hit the URLs in TESTS based on the outcome
fixture('Verifying')
.beforeEach(async t =>{
console.log("Execution Started ");
const args = minimist(process.argv.slice(2));
var environment = args.env;
if(environment == 'Test')
{
t.ctx.Connectionstring=config.Test.Connectionstring;
t.ctx.Url=config.Test.Url;
}
else if(environment == 'Stage')
{
t.ctx.Connectionstring=config.Stage.Connectionstring;
t.ctx.Url=config.Stage.Url;
}
else if(environment == 'Prod')
{
t.ctx.Connectionstring=config.Prod.Connectionstring;
t.ctx.Url=config.Prod.Url;
}
test.page(t.ctx.Url)
("TC1 - Report Batches", async t => {
await t
.typeText(lgpage.username, 'abc)
.typeText(lgpage.password,'abc')
.click(lgpage.submit)
})
test.page(t.ctx.Url) does not work. Even if I give fixture.page(t.ctx.Url) does not work both the time it is giving the error:
"Cannot implicitly resolve the test run in the context of which the test controller action should be executed. Use the test function's 't' argument instead."
I also tried navigateTo(t.ctx.Url) this does not work.
Upvotes: 1
Views: 171
Reputation: 5227
fixture('Verifying')
.beforeEach(async t =>{
console.log("Execution Started ");
const args = minimist(process.argv.slice(2));
var environment = args.env;
if(environment == 'Test')
{
t.ctx.Connectionstring=config.Test.Connectionstring;
t.ctx.Url=config.Test.Url;
}
else if(environment == 'Stage')
{
t.ctx.Connectionstring=config.Stage.Connectionstring;
t.ctx.Url=config.Stage.Url;
}
else if(environment == 'Prod')
{
t.ctx.Connectionstring=config.Prod.Connectionstring;
t.ctx.Url=config.Prod.Url;
}
test("TC1 - Report Batches", async t => {
await t
.navigateTo(t.ctx.Url)
.typeText(lgpage.username, 'abc)
.typeText(lgpage.password,'abc')
.click(lgpage.submit)
})
Upvotes: 2