最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

typescript - Is it possible to enable options like --use-fake-device-for-media-stream on existing browser session - Stack Overfl

programmeradmin0浏览0评论

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.

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论