ARTICLE AD BOX
I am validating a scenario where user stops the screen and checks the notification "Screen share is off".
Right now, I am automating these tests in Chrome browser using the Chrome fake media for this.
launchOptions: { args: [ '--use-fake-ui-for-media-stream', '--use-fake-device-for-media-stream', ], },Can we automate this?
What I tried so far
Used stream track to stop the video feed - works partiallyIt stops the video but display as black screen, whcih does not trigger the stop screen condition:
if (window.__capturedDisplayStreams && Array.isArray(window.__capturedDisplayStreams)) { // @ts-ignore window.__capturedDisplayStreams.forEach((stream: MediaStream) => { stream.getTracks().forEach(track => { if (track.readyState === 'live') { console.log(`[STOP] Stopping captured display track: ${track.label} (${track.kind})`); track.stop(); stoppedTracks.push(track.label); } }); }); } Used pwDisplayStreams - not working if (window.__pwDisplayStreams) { // @ts-ignore window.__pwDisplayStreams.forEach((s: MediaStream) => { s.getTracks().forEach(t => { if (t.kind === 'video' && t.readyState === 'live') { console.log(`[STOP] Stopping Playwright display track: ${t.label}`); t.stop(); stoppedTracks.push(t.label); } }); }); }Used routing - not working
await page.route('**/*/screen-stream/*', route => route.abort());Nothing seems to be working. Is it possible to automate this scenario, or not?
If yes, could you share your thoughts on how to achieve the desired output?
