getUserMedia with microphone fails
See original GitHub issueBug
Requests to access the user’s microphone using getUserMedia()
fail and crash Cypress test.
Current behavior:
I have a web application which allows users to do voice recordings in their browser. Getting access to the microphone is done through the following
var constraints = {
audio: true,
video: false
};
navigator.mediaDevices
.getUserMedia(constraints)
.then(recordAudio);
Cypress fails this test due to the call .getUserMedia()
with the error:
Uncaught TypeError: Cannot read property ‘getUserMedia’ of undefined
I have seen that some work has been done with webcams, but I’m not finding anything for microphones.
Desired behavior:
I would like this to not fail, so that I can test the application.
Steps to reproduce:
index.html:
<!DOCTYPE html>
<html>
<head>
<script>
window.onload = function() {
var constraints = {
audio: true,
video: false
};
navigator.mediaDevices.getUserMedia(constraints);
};
</script>
</head>
<body>
<p>Hello World</p>
</body>
</html>
Test:
cy.visit("/index.html");
Versions
macOS Mojave Cypress 3.2.0
Issue Analytics
- State:
- Created 4 years ago
- Comments:13 (6 by maintainers)
Top Results From Across the Web
Common getUserMedia() Errors - Deconstruct
The error is an object of type OverconstrainedError , and has a constraint property whose string value is the name of a constraint...
Read more >getUserMedia silently fails on user declining permission to ...
Doesn't Firefox fire an error when the user declines the usage of the microphone when getUserMedia is called?
Read more >MediaDevices.getUserMedia() - Web APIs | MDN
First, getUserMedia() must always get user permission before opening any media gathering input such as a webcam or microphone. Browsers may ...
Read more >112367 - getUserMedia() doesn't work for microphone input
I have successfully added stream and send through peer connection and sound is very good, but the problem I can't analyze the sound...
Read more >WebRTC Fix For getUserMedia Undefined On Local Hosts
What this means is that is the browser does not have access camera or microphone of the computer. The error is not a...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
this error is due to chrome and other browsers block microphone access to not https sites so try to install SSL you can get your free one from here https://www.sslforfree.com/ and follow the tutorial
You can follow the same basic procedure as @jennifer-shehane’s comment on the webcam issue (#2704), but instead of using
--use-file-for-fake-video-capture
, you can use--use-file-for-fake-audio-capture
:In
cypress/plugins/index.js
: