我有一台m1芯片的笔记本电脑,我在上面用下面的yml文件运行docker,用不同浏览器的节点运行网格,这些节点正确地连接到集线器,但在chrome上运行测试时,它会崩溃,在firefox中运行良好的地方永远不会启动测试。
# To execute this docker-compose yml file use `docker-compose -f docker-compose-v3.yml up`
# Add the `-d` flag at the end for detached execution
# To stop the execution, hit Ctrl+C, and then `docker-compose -f docker-compose-v3.yml down`
version: "3"
services:
chrome:
image: selenium/node-chrome:4.5.0-20221017
shm_size: 2gb
depends_on:
- selenium-hub
environment:
- SE_EVENT_BUS_HOST=selenium-hub
- SE_EVENT_BUS_PUBLISH_PORT=4442
- SE_EVENT_BUS_SUBSCRIBE_PORT=4443
edge:
image: selenium/node-edge:4.5.0-20221017
shm_size: 2gb
depends_on:
- selenium-hub
environment:
- SE_EVENT_BUS_HOST=selenium-hub
- SE_EVENT_BUS_PUBLISH_PORT=4442
- SE_EVENT_BUS_SUBSCRIBE_PORT=4443
firefox:
image: selenium/node-firefox:4.5.0-20221017
shm_size: 2gb
depends_on:
- selenium-hub
environment:
- SE_EVENT_BUS_HOST=selenium-hub
- SE_EVENT_BUS_PUBLISH_PORT=4442
- SE_EVENT_BUS_SUBSCRIBE_PORT=4443
selenium-hub:
image: selenium/hub:4.5.0-20221017
container_name: selenium-hub
ports:
- "4442:4442"
- "4443:4443"
- "4444:4444"
这是docker撰写的文件。我使用的测试代码是
ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.setCapability(CapabilityType.UNHANDLED_PROMPT_BEHAVIOUR, UnexpectedAlertBehaviour.IGNORE);
driver = new RemoteWebDriver(new URL("http://localhost:4444/"),chromeOptions);
driver.manage().window().maximize();
driver.get("https://stackoverflow.com/");
selenium-hub | 11:19:50.008 WARN [SeleniumSpanExporter$1.lambda$export$1] - org.openqa.selenium.SessionNotCreatedException: Could not start a new session. Could not start a new session. Error while creating session with the driver service. Stopping driver service: Could not start a new session. Response code 500. Message: unknown error: Chrome failed to start: crashed.
selenium-hub | (unknown error: DevToolsActivePort file doesn't exist)
selenium-hub | (The process started from chrome location /usr/bin/google-chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.)
selenium-hub | Host info: host: '6857544abb6a', ip: '172.18.0.3'
selenium-hub | Build info: version: '4.5.0', revision: 'fe167b119a'
selenium-hub | System info: os.name: 'Linux', os.arch: 'amd64', os.version: '5.10.124-linuxkit', java.version: '11.0.16'
selenium-hub | Driver info: driver.version: unknown
selenium-hub | Build info: version: '4.5.0', revision: 'fe167b119a'
selenium-hub | System info: os.name: 'Linux', os.arch: 'amd64', os.version: '5.10.124-linuxkit', java.version: '11.0.16'
selenium-hub | Driver info: driver.version: unknown
selenium-hub | Build info: version: '4.5.0', revision: 'fe167b119a'
selenium-hub | System info: os.name: 'Linux', os.arch: 'amd64', os.version: '5.10.124-linuxkit', java.version: '11.0.16'
selenium-hub | Driver info: driver.version: unknown
selenium-hub | at org.openqa.selenium.grid.node.remote.RemoteNode.newSession(RemoteNode.java:150)
selenium-hub | at org.openqa.selenium.grid.distributor.local.LocalDistributor.startSession(LocalDistributor.java:639)
selenium-hub | at org.openqa.selenium.grid.distributor.local.LocalDistributor.newSession(LocalDistributor.java:558)
selenium-hub | at org.openqa.selenium.grid.distributor.local.LocalDistributor$NewSessionRunnable.handleNewSessionRequest(LocalDistributor.java:812)
selenium-hub | at org.openqa.selenium.grid.distributor.local.LocalDistributor$NewSessionRunnable.lambda$run$1(LocalDistributor.java:773)
selenium-hub | at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
selenium-hub | at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
selenium-hub | at java.base/java.lang.Thread.run(Thread.java:829)
selenium-hub |
selenium-hub | 11:19:50.011 WARN [SeleniumSpanExporter$1.lambda$export$3] - {"traceId": "f043d429f257e3b7a5422356635be50f","eventTime": 1666178390003999793,"eventName": "exception","attributes": {"exception.message": "Unable to create session: Could not start a new session. Could not start a new session. Error while creating session with the driver service. Stopping driver service: Could not start a new session. Response code 500. Message: unknown error: Chrome failed to start: crashed.n (unknown error: DevToolsActivePort file doesn't exist)n (The process started from chrome location u002fusru002fbinu002fgoogle-chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.) nHost info: host: '6857544abb6a', ip: '172.18.0.3'nBuild info: version: '4.5.0', revision: 'fe167b119a'nSystem info: os.name: 'Linux', os.arch: 'amd64', os.version: '5.10.124-linuxkit', java.version: '11.0.16'nDriver info: driver.version: unknownnBuild info: version: '4.5.0', revision: 'fe167b119a'nSystem info: os.name: 'Linux', os.arch: 'amd64', os.version: '5.10.124-linuxkit', java.version: '11.0.16'nDriver info: driver.version: unknownnBuild info: version: '4.5.0', revision: 'fe167b119a'nSystem info: os.name: 'Linux', os.arch: 'amd64', os.version: '5.10.124-linuxkit', java.version: '11.0.16'nDriver info: driver.version: unknown","exception.stacktrace": "org.openqa.selenium.SessionNotCreatedException: Could not start a new session. Could not start a new session. Error while creating session with the driver service. Stopping driver service: Could not start a new session. Response code 500. Message: unknown error: Chrome failed to start: crashed.n (unknown error: DevToolsActivePort file doesn't exist)n (The process started from chrome location u002fusru002fbinu002fgoogle-chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.) nHost info: host: '6857544abb6a', ip: '172.18.0.3'nBuild info: version: '4.5.0', revision: 'fe167b119a'nSystem info: os.name: 'Linux', os.arch: 'amd64', os.version: '5.10.124-linuxkit', java.version: '11.0.16'nDriver info: driver.version: unknownnBuild info: version: '4.5.0', revision: 'fe167b119a'nSystem info: os.name: 'Linux', os.arch: 'amd64', os.version: '5.10.124-linuxkit', java.version: '11.0.16'nDriver info: driver.version: unknownnBuild info: version: '4.5.0', revision: 'fe167b119a'nSystem info: os.name: 'Linux', os.arch: 'amd64', os.version: '5.10.124-linuxkit', java.version: '11.0.16'nDriver info: driver.version: unknownntat org.openqa.selenium.grid.node.remote.RemoteNode.newSession(RemoteNode.java:150)ntat org.openqa.selenium.grid.distributor.local.LocalDistributor.startSession(LocalDistributor.java:639)ntat org.openqa.selenium.grid.distributor.local.LocalDistributor.newSession(LocalDistributor.java:558)ntat org.openqa.selenium.grid.distributor.local.LocalDistributor$NewSessionRunnable.handleNewSessionRequest(LocalDistributor.java:812)ntat org.openqa.selenium.grid.distributor.local.LocalDistributor$NewSessionRunnable.lambda$run$1(LocalDistributor.java:773)ntat java.baseu002fjava.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)ntat java.baseu002fjava.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)ntat java.baseu002fjava.lang.Thread.run(Thread.java:829)n","exception.type": "org.openqa.selenium.SessionNotCreatedException","logger": "org.openqa.selenium.grid.distributor.local.LocalDistributor","request.payload": "[Capabilities {browserName: chrome, goog:chromeOptions: {args: [], extensions: []}, unhandledPromptBehavior: ignore}]"}}
selenium-hub |
selenium-hub | 11:19:50.024 WARN [SeleniumSpanExporter$1.lambda$export$3] - {"traceId": "f043d429f257e3b7a5422356635be50f","eventTime": 1666178390028315173,"eventName": "HTTP request execution complete","attributes": {"http.flavor": 1,"http.handler_class": "org.openqa.selenium.grid.sessionqueue.local.LocalNewSessionQueue","http.host": "localhost:4444","http.method": "POST","http.request_content_length": "451","http.scheme": "HTTP","http.status_code": 500,"http.target": "u002fsession","http.user_agent": "seleniumu002f4.5.0 (java mac)"}}
selenium-hub |
尝试使用seleniarm/hub
而不是selenium/hub
,这是一个基于社区的官方映像版本,专为多芯片组架构构建。https://github.com/seleniumhq-community/docker-seleniarm