如何使用可见的浏览器在Docker容器中运行Selenium测试?

如何使用可见的浏览器在Docker容器中运行Selenium测试?

问题描述:

如果我想在带有可见(而非无头)浏览器的Docker容器中运行Selenium测试,我有什么选择?

If I want to run Selenium tests inside a Docker container with a visible (not headless) browser, what are my options?

  • 我需要使用VNC之类的远程显示查看器吗?
  • 是否可以在主机上使用浏览器?(即,不在Docker容器中的浏览器).如何运作?
  • 还有其他选择吗?

我的结论是,这样做的规范方法是在Docker容器上使用轻量级桌面环境(例如LXDE)运行X.然后,您可以使用VNC客户端连接到它.无法在主机上使用浏览器.

My conclusion is that the canonical way of doing this is to run X with a lightweight desktop environment such as LXDE on the Docker container. Then you can connect to it with a VNC client. Using a browser on the host is not possible.

有关其他选项,请参见其他答案.

For other options, see the other answers.