【发布时间】:2020-09-18 02:22:30
【问题描述】:
所以我试图在 docker 容器中配置 selenium,以便与 behat 一起使用,当我到达 http://localhost:4444/status 时,集线器的状态为 not ready :
{
"value": {
"ready": false,
"message": "Selenium Grid not ready.",
"nodes": [
{
"id": "f746de23-58e4-499d-85fd-9bad4f904488",
"uri": "http:\u002f\u002f172.22.0.5:5555",
"maxSessions": 2,
"stereotypes": [
{
"capabilities": {
"browserName": "chrome"
},
"count": 2
}
],
"sessions": [
]
}
]
}
}
当我运行测试时:
Could not open connection: Payload received from webdriver is valid but unexpected json: {
"value": {
"error": "session not created",
"message": "Unable to find provider for session: Capabilities {browser: firefox, browserName: chrome, ignoreZoomSetting: false, name: Behat feature suite, tags: [509f70556c1c, PHP 7.4.9]}, Capabilities {browserName: chrome}, Capabilities {browserName: firefox}, Capabilities {}\nBuild info: version: '4.0.0-alpha-7', revision: '117b9d61c9'\nSystem info: host: '7f39dcd595c7', ip: '172.22.0.2', os.name: 'Linux', os.arch: 'amd64', os.version: '4.19.76-linuxkit', java.version: '1.8.0_265'\nDriver info: driver.version: unknown",
"stacktrace": "org.openqa.selenium.SessionNotCreatedException: Unable to find provider for session: Capabilities {browser: firefox, browserName: chrome, ignoreZoomSetting: false, name: Behat feature suite, tags: [509f70556c1c, PHP 7.4.9]}, Capabilities {browserName: chrome}, Capabilities {browserName: firefox}, Capabilities {}\nBuild info: version: '4.0.0-alpha-7', revision: '117b9d61c9'\nSystem info: host: '7 (Behat\Mink\Exception\DriverException)
我尝试了很多配置,主要是在 behat.yml 中的 wd_host 参数中,但我尝试的所有内容(不同的 url、不同的端口...)都给我带来了错误。
我的 docker-composer.yml:
version: '3'
services:
chrome:
image: selenium/node-chrome:4.0.0-alpha-7-prerelease-20200907
volumes:
- /dev/shm:/dev/shm
depends_on:
- selenium-hub
environment:
- SE_EVENT_BUS_HOST=selenium-hub
- SE_EVENT_BUS_PUBLISH_PORT=4442
- SE_EVENT_BUS_SUBSCRIBE_PORT=4443
ports:
- "6900:5900"
selenium-hub:
image: selenium/hub:4.0.0-alpha-7-prerelease-20200907
container_name: selenium-hub
ports:
- "4442:4442"
- "4443:4443"
- "4444:4444"
restart: always
我的 behat.yml:
extensions:
Behat\MinkExtension:
base_url: "http://localhost"
browser_name: 'chrome'
sessions:
my_session:
selenium2:
wd_host: "http://selenium-hub:4444"
browser: chrome
capabilities: { "browserName": "chrome"}
FriendsOfBehat\SymfonyExtension: null
有一刻我以为它与“功能”参数有关,所以我尝试将东西放入其中,但它没有改变任何东西,我想如果只是这样,集线器仍然会告诉我它准备好了。
有什么想法吗?谢谢
【问题讨论】:
标签: docker selenium symfony behat