Upload and test custom media

Test the custom media files in your test. The guide helps you with the following:

  1. Upload the media on BrowserStack
  2. Use the uploaded media in your tests

Upload the media

The API to upload the media file(images/videos) on BrowserStack:

curl -u "YOUR_USERNAME:YOUR_ACCESS_KEY" -X POST "https://api-cloud.browserstack.com/app-automate/upload-media" -F "file=@/path/to/media/file/mediaFile.jpg" -F 'data={"custom_id": "MyMedia"}'

Sample Response:

{"media_url":"media://21d66a8a0471097bbf5789330129e9ab97e467e3","custom_id":"MyMedia","shareable_id":"YOUR_USERNAME/MyMedia"}

Use the uploaded media in your tests

After uploading the custom media files, you can use it in your tests using browserstack.uploadMedia capability.

Capability Description Values
browserstack.uploadMedia Use your uploaded images or videos in the test The media_url returned on the upload response.
Example: [“media://hashedid”, “media://hashedid”]

Note:

  1. Only 5 files are allowed to be passed(per test)
  2. Supported format for images are JPG, JPEG, PNG, GIF, BMP and max file size allowed for images is 10MB
  3. Supported format for videos are .mp4, .mov and .3gp and max file size allowed for videos is 50MB
desired_caps = {
    'browserstack.uploadMedia': '{"media://a73cd169be98006b6ca8b9b1feaa51c5395df1ad","media://4f13c09b8428ed1b67g561db63af01d44ca540b"}'

We're sorry to hear that. Please share your feedback so we can do better







Contact our Support team for immediate help while we work on improving our docs.

We're continuously improving our docs. We'd love to know what you liked






Thank you for your valuable feedback

Is this page helping you?

Yes
No

We're sorry to hear that. Please share your feedback so we can do better







Contact our Support team for immediate help while we work on improving our docs.

We're continuously improving our docs. We'd love to know what you liked






Thank you for your valuable feedback!

Talk to an Expert
Talk to an Expert