Here is the example i am trying to use to setup fake media streaming. But in this case it always opens a new browser instance and with this i am able to setup the fake media streaming in the new browser session using await context.newPage()
. Instead i want to use the existing browser session to setup the fake media streaming for the same session.
const projectRoot = pathObj.resolve(process.cwd());
console.log(`Current Dir: ${projectRoot}`);
const strVideoPath = projectRoot + "/tests/data/" + strVideoFileName;
console.log(`File Path: ${strVideoPath}`);
const launchOptions = {
args: [
'--use-fake-device-for-media-stream',
'--use-fake-ui-for-media-stream',
`--use-file-for-fake-video-capture=${strVideoPath}`
]
};
const browser = await chromium.launch(launchOptions);
const context = await browser.newContext();
this.page = await context.newPage(); //This works but opens multiple new browser sessions.
// I already have a browser session open under this.page which I am reassigning with conext.newPage() here.
What can i do to avoid multiple browser launch and also what is the best way to use the existing browser page instead of launching a new one.