在D中运行selenium测试

2024-04-16 18:26:25 发布

您现在位置:Python中文网/ 问答频道 /正文

我编写了一个selenium脚本,当我使用cmd启动它时,它运行良好。你知道吗

我现在想在docker中执行这个脚本,这样它就可以很容易地从任何一台机器上一键启动。你知道吗

我使用基本映像FROM selenium/standalone-chrome-debug编写了一个Dockerfile

我把剧本改成这样:

driver = webdriver.Remote("http://127.0.0.1:4444/wd/hub", DesiredCapabilities.CHROME)
driver.maximize_window()
driver.get("www.google.com")

但当我启动它时,我有以下错误:

urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='127.0.0.1', port=4444): Max retries exceeded with url: /wd/hub/session (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7fd11b9e3b90>: Failed to establish a new connection: [Errno 111] Connection refused',))

我是docker和selenium的新手,所以我可能忘了什么。你知道吗


Tags: dockerfromdebug脚本cmd机器driverselenium