page gets closed after running the before: in config, trying to access the same page in scenarios, its says :" Target page, context or browser has been closed" #3309
ashokyamsani
started this conversation in
Artillery
Replies: 1 comment
-
@hassy please do let me know in case you need any information. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
my yaml
config:
This is a test server run by team Artillery
It's designed to be highly scalable
target: https://mytargeturl.com
payload:
path: '../datafiles/users.csv'
fields:
- 'username'
- 'password'
engines:
playwright:
aggregateByName: true
launchOptions:
headless: false
processor: '..\TSprocessors\ar_login.ts'
phases:
- duration: 3
name: 'Phase1'
arrivalRate: 1
# rampTo: 2
before:
engine: playwright
flow:
- log: 'UserLogin'
testFunction: 'LoginToNirmaan'
scenarios:
# beforeScenario: 'LoginToNirmaan'
engine: playwright
testFunction: "OpenProject"
variables :
json:
username: "{{ username }}"
password: "{{ password }}"
import { Viewer } from "../../playwright-scenarios/Viewer/viewer";
import { Login } from "../../playwright-scenarios/loginPage/login";
import { chromium, Browser, Page } from 'playwright';
let viewer : Viewer;
let login : Login;
let usercount =0;
let browser:Browser;
//page, vuContext, events, test
export async function LoginToNirmaan(page,context,events, test) {
const { step } = test;
login = new Login(page);
usercount = context.vars.userId;
var username = context.vars.username;
var password = context.vars.password;
//Goto Homepage
await step("Navigate to Login Page", async()=>{
try {
await login.GotoLoginPage(page);
await login.Login(page,username,password);
console.log("User from NavigateToLogin " +username)
context.vars.page = page;
} catch (error) {
console.error('drrror'+error)
// step.fail();
}
});
}
export async function OpenProject(page,vuContext, events, test) {
const { step } = test;
var username = vuContext.vars.username;
viewer = new Viewer(page);
//Goto Homepage
await step("Navigate to Viewer Page", async()=>{
try {
if(username=='testuser@vconstruct.in')
{ viewer.LoadBlock71Project(page);}
else{
console.log('NOthing to load on viewer page');
}
});
}
Beta Was this translation helpful? Give feedback.
All reactions