When accessing the Selenium Grid hub at http://127.0.0.1:4444/wd/hub using the selenium/standalone-chrome container without modifications, the following error may appear:
disconnected: unable to send message to renderer
(failed to check if window was closed: disconnected: not connected to DevTools)
(Session info: chrome=115.0.5790.110)
Stacktrace:
#0 0x556589d13783 <unknown>
#1 0x556589a3f917 <unknown>
#2 0x556589a24ad2 <unknown>
#3 0x556589a254df <unknown>
#4 0x556589a423cd <unknown>
#5 0x556589a42c60 <unknown>
#6 0x556589a45720 <unknown>
#7 0x556589a457dc <unknown>
#8 0x556589a7e048 <unknown>
#9 0x556589a7e411 <unknown>
#10 0x556589ab96b1 <unknown>
#11 0x556589a9ee2d <unknown>
#12 0x556589ab70d9 <unknown>
#13 0x556589a9ebd3 <unknown>
#14 0x556589a72a7b <unknown>
#15 0x556589a7381e <unknown>
#16 0x556589cd4e98 <unknown>
#17 0x556589cd8d67 <unknown>
#18 0x556589ce332c <unknown>
#19 0x556589cd9993 <unknown>
#20 0x556589ca8827 <unknown>
#21 0x556589cfd8a8 <unknown>
#22 0x556589cfda36 <unknown>
#23 0x556589d0c5f3 <unknown>
#24 0x7f40a3a85609 start_thread
This disconnection error, unable to send message to renderer, often occurs due to insufficient shared memory (/dev/shm) allocated to the Chrome container. Chrome utilizes shared memory for inter-process communication and rendering operations. A resolution is to configure the container's shared memory size explicitly in the docker-compose.yml file.
Below is a sample Docker Compose configuraton implementing this fix. The critical addition is the shm_size parameter for the Selenium service.
version: '3.9'
services:
automation_app:
container_name: "app-container"
image: python:3.11-slim
volumes:
- ./automation_project:/app
working_dir: /app
command: sh -c "pip install --upgrade pip && pip install -r deps.txt && python driver.py"
depends_on:
- selenium_driver
- database
networks:
- automation_net
selenium_driver:
container_name: "selenium-chrome-container"
image: selenium/standalone-chrome
volumes:
- ./automation_project:/app
ports:
- "4444:4444"
shm_size: 2gb
networks:
- automation_net
database:
container_name: "app-database-container"
image: mongo
ports:
- "27018:27017"
networks:
- automation_net
networks:
automation_net:
driver: bridge
In this configuration, shm_size: 2gb allocates 2 gigabytes of shared memory to the selenium_driver container. This allocation provides adequate resources for Chrome's rendering processes, preventing the disconnection error. The value can be adjusted based on specific test requirements and avaliable system resources.
The Python application service mounts the project directory and installs dependencies before execution. It depends on the Selenium and database services, ensuring they start in the correct order. All services are connected via a custom bridge network automation_net to facilitate inter-container communication.