Chaika Bogdan
Chaika Bogdan

Reputation: 1

Web camera mocks not working with S3 pre-signed videos in Playwright

I have several Playwright tests that use a webcam to capture videos and photos. Now they work with stubs via '--use-fake-ui-for-media-stream','--use-fake-device-for-media-stream'

I would really like to dynamically use video mocks for happy e2e tests.

After studying the problem a little, I managed to mock public .mp4 streams into the video element used for the webcam feed.

In my CI/CD pipeline, all test data (including camera videos) are stored as pre-signed AWS S3 links like https://my-e2e.s3.amazonaws.com/resources/my-face.webm?AWSAccessKeyId=ABC123FAKE&Signature=ABC123FAKED&Expires=1660724194

But such videos don't work at all with the suggested CaptureStream workaround.

You can check the working snippet in jsfiddle playground

I have a bad feeling it might be restricted by:

Attempting to use captureStream() with a media element that implements content protection via Encrypted Media Extensions will throw an exception.

Or I am missing something about streaming videos from AWS...

UPD Oct 2022: Adding * as allowed origin to CORS settings of S3 bucket resolved my issue.

References:

Upvotes: 0

Views: 510

Answers (0)

Related Questions