【问题标题】:How to access app running in localhost when testcafe running in docker container?当 testcafe 在 docker 容器中运行时,如何访问在 localhost 中运行的应用程序?
【发布时间】:2019-10-19 07:07:12
【问题描述】:

我在自定义 docker 容器中运行 testcafe,并且我的 Web 应用程序在不同的 docker 容器(或 docker-compose)中运行。如果我从网络浏览器使用该应用程序,我会转到 localhost:8080

如何从 testcafe docker 容器访问应用程序?

> docker run -ti mycustom/testcafe firefox /tests/*

Error details:
Failed to find a DNS-record for the resource at "http://localhost:8080/".

我尝试添加--network=network-name,但没有帮助。

【问题讨论】:

  • 您能提供一个minimal reproducible example 来说明您想要做什么吗?当你说“在 localhost 中运行”时,它是哪个 localhost——物理主机的 localhost、同一个 Docker 容器的 localhost、不同的容器或主机的 localhost?
  • 感谢您的回答和提问。编辑了我原来的问题。所以,我的应用程序在 docker 中运行,并在另一个容器中运行 testcafe 测试。

标签: docker automated-tests e2e-testing web-testing testcafe


【解决方案1】:

您不需要使用 docker-compose 显式配置网络。不使用 docker-compose 的解决方案,请参考this 线程。

【讨论】:

    猜你喜欢
    • 2019-03-09
    • 1970-01-01
    • 2018-07-15
    • 2019-08-25
    • 2018-12-26
    • 1970-01-01
    • 2020-08-10
    • 2018-06-25
    • 2019-08-23
    相关资源
    最近更新 更多