Gop*_*hna 3 selenium automation selenium-webdriver docker dockerfile
我正在尝试运行位于我的自动化容器中的自动化 GUI 测试套件。
我单独下载了独立的 selenium-firefox 映像并作为在端口 4444 上运行的容器运行。它运行在
localhost:4444/wd/hub
Run Code Online (Sandbox Code Playgroud)
现在,我正在尝试运行自动化容器中的测试套件,我使用下面的代码在无头模式下运行,以在我的 robotsframework 测试套件中达到 firefox 版本的 selenium。
Open Browser http://www.youtube.com headlessfirefox remote_url=http://localhost:4444/wd/hub
Run Code Online (Sandbox Code Playgroud)
当我从我的机器运行测试套件时,这种方法工作正常,当我在自动化容器内运行它时,它会失败。
有什么方法可以让我的自动化容器到达 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',))
Run Code Online (Sandbox Code Playgroud)
任何帮助将不胜感激
您需要使用要创建的所有容器创建 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
Run Code Online (Sandbox Code Playgroud)
并在容器内使用主机名“chrome”,它将使用它,如下所示:
cls.driver = webdriver.Remote(command_executor='http://chrome:4444/wd/hub',desired_capabilities=DesiredCapabilities.CHROME)
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
5671 次 |
最近记录: |