gpt4 book ai didi

docker - 如何从另一个容器连接到独立的 selenium-firefox 容器

转载 作者:行者123 更新时间:2023-12-05 01:31:02 25 4
gpt4 key购买 nike

我正在尝试运行位于我的自动化容器中的自动化 GUI 测试套件。

我单独下载了独立的 selenium-firefox 图像并作为容器运行在端口 4444 上运行。它正在运行

localhost:4444/wd/hub

现在,我正在尝试运行我的自动化容器中的测试套件,我使用以下代码以 headless 模式运行,以在我的机器人框架测试套件中使用 selenium 的 firefox 版本。

Open Browser      http://www.youtube.com    headlessfirefox    remote_url=http://localhost:4444/wd/hub

当我从我的机器上运行我的测试套件时,这种方法工作正常,当我在自动化容器中运行它时失败。

有什么方法可以让我的自动化容器到达 selenium-firefox 容器以使用浏览器。

错误:

C: 10: Open Chrome headless                                          
/usr/local/lib/python3.6/site-packages/requests/__init__.py:91:
RequestsDependencyWarning: urllib3 (1.26.3) or chardet (3.0.4) doesn't
match a supported version!
RequestsDependencyWarning)
[ WARN ] Retrying (Retry(total=2, connect=None, read=None, redirect=None,
status=None)) after connection broken by
'NewConnectionError('<urllib3.connection.HTTPConnection object at
0x7f4a322440b8>: Failed to establish a
[ WARN ] Retrying (Retry(total=1, connect=None, read=None, redirect=None,
status=None)) after connection broken by
'NewConnectionError('<urllib3.connection.HTTPConnection object at
0x7f4a32244710>: Failed to establish a
new connection: [Errno 111] Connection refused',)': /wd/hub/session
[ WARN ] Retrying (Retry(total=0, connect=None, read=None, redirect=None,
status=None)) after connection broken by
'NewConnectionError('<urllib3.connection.HTTPConnection object at
0x7f4a32235710>: Failed to establish a
new connection: [Errno 111] Connection refused',)': /wd/hub/session
| FAIL |
MaxRetryError: HTTPConnectionPool(host='localhost', port=4444): Max
retries exceeded with url: /wd/hub/session (Caused by
NewConnectionError('<urllib3.connection.HTTPConnection object at
0x7f4a32235438>: Failed to establish a new connection: [Errno 111]
Connection refused',))

如有帮助将不胜感激

最佳答案

您需要使用您要创建的所有容器创建 docker-compose.yml 文件:

version: '3.8'
services:
chrome:
image: selenium/standalone-chrome:85.0
hostname: chrome
ports:
- "4444:4444"
e2e-tests:
build: .
depends_on:
- chrome

并在容器内使用主机名“chrome”,它将像这样使用它:

cls.driver = webdriver.Remote(command_executor='http://chrome:4444/wd/hub',desired_capabilities=DesiredCapabilities.CHROME)

关于docker - 如何从另一个容器连接到独立的 selenium-firefox 容器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66597600/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com