selenium - 使用音频时,Docker中的Firefox中的getUserMedia无法正常工作

标签 selenium firefox docker webrtc getusermedia

在Docker中使用Firefox 52+时,我遇到了WebRTC的getUserMedia函数的怪异行为。复制它的步骤是:

1)在Docker中运行Selenium Hub:

docker run --rm --name selenium-hub -p 4444:4444 selenium/hub:3.4.0

2)在集线器中注册Firefox浏览器:
docker run --rm --link selenium-hub:hub -p 5555:5555 -p 5900:5900 selenium/node-firefox-debug:3.4.0

注意1:此命令使用的是node-firefox镜像的调试版本,因为我们要使用VNC连接到浏览器(在容器中)

注意2:此版本(3.4.0)使用的是Firefox53。自Firefox 52(即52、53、54)以来,也会发生此问题,但在Firefox 51中不会发生此问题(node-firefox-debug:3.1.0) )

3)使用VNC客户端连接到浏览器(Linux中的URL:vnc://127.0.0.1:5900,密码:secret)

4)强制在dockerized浏览器中使用伪造的媒体。可以通过在Firefox的高级配置中将配置项true设置为media.navigator.streams.fake来完成(选项about:config):

enter image description here

5)在Docker的Firefox中打开getUserMedia samples page。例如,Basic getUserMedia demo可以正常工作:

enter image description here

我检查了这个演示是否正常,因为在mediaConstraints音频标志设置为false :
var constraints = window.constraints = {
  audio: false,
  video: true
};

但是,将音频标志设置为true的其他任何演示都将无法正常工作,并且getUserMedia函数会停滞。

奇怪的是,这种行为只能在Docker中重现,即,直接在主机中运行的任何版本的Firefox都可以正常运行。似乎这里存在某种错误,但我不确定该困惑的哪一部分。

问题出在哪里? docker ?火狐浏览器?

最佳答案

我们在travis-ci上运行adapter.js时遇到了同样的问题。解决方案显示为in this pull request-您需要启动pulseaudio

关于selenium - 使用音频时,Docker中的Firefox中的getUserMedia无法正常工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44775411/

相关文章:

docker - 无法停止或删除Docker中的容器,显示权限被拒绝

python - 如何解决 Docker 镜像中的 Tesseract "Failed loading language ' eng'"问题

javascript - 使用 Selenium 选择带有角色复选框的 div 元素

python - Python中的Selenium下载文件: even after setting Firefox Profile the Download Window opens

java - Cucumber Scenario Outline 上的 Example 表是否可以有空值?

javascript - Bootstrap 3 : Firefox bug - Cannot set div height

css - @font-face : flash of STYLED text on Firefox (FOST)

python - 如何正确设置 Windows7 以将 Selenium 与 Firefox [TDD with Python] 结合使用?

Firefox 插件下载.jsm

windows - Windows 10 上的 Docker : How to move existing containers & images to new location?