Can the binary be used with selenium grid? #371
-
|
I'm aware that selenium leaves a lot of detected signals but my goal is to use the binary with the selenium grid infrastructure and launch the service using the docker-compose to then use it for scraping: version: "3"
services:
selenium-hub:
image: selenium/hub:4.41.0
container_name: selenium-hub
ports:
- "4442:4442"
- "4443:4443"
- "4444:4444"
environment:
- JAVA_OPTS=-Djdk.httpclient.websocket.intermediateBufferSize=3000000
- SE_EVENT_BUS_HOST=selenium-hub
networks:
- grid-network
chrome:
image: selenium/node-chrome:145.0
shm_size: 2gb
depends_on:
- selenium-hub
environment:
- JAVA_OPTS=-Djdk.httpclient.websocket.intermediateBufferSize=3000000
- SE_EVENT_BUS_HOST=selenium-hub
- SE_NODE_GRID_URL=http://localhost:4444
- SE_NODE_SESSION_TIMEOUT=120
- SE_NODE_MAX_SESSIONS=4
networks:
- grid-network
networks:
grid-network:
driver: bridgeand maybe changing this binary argument and putting the cloakbrowser one: |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
|
Short answer: technically yes, but it requires a custom node image — the official Selenium Grid with a custom binary works via the node stereotype mechanism you found, but there are a few constraints specific to CloakBrowser: The core pattern (standalone Selenium, no Grid) already works — For Grid, you'd need to:
One important caveat: the stealth patches are compiled into the binary, so they're always active regardless of Grid. What you won't get over Grid is Has anyone on the team tried building a custom node image with this approach? Happy to share more detail on the Dockerfile structure if it'd help. |
Beta Was this translation helpful? Give feedback.
-
|
Thanks for the detailed question, and thanks @salvador-castro for the solid answer — it's accurate. We actually built and ran this on a real Grid to confirm the snippet works, so here's a tested setup. One correction first: the free binary is now Chromium 146 (not 145), and Pro is 148. That matters because ChromeDriver enforces a major-version match — your Grid node's driver major must equal the binary's major. The cleanest path is to base your node on the official
FROM selenium/node-chrome:146.0.7680.177-chromedriver-146.0.7680.165-grid-4.44.0-20260505
USER root
RUN apt-get update && apt-get install -y --no-install-recommends python3 python3-pip \
&& rm -rf /var/lib/apt/lists/*
RUN pip3 install --break-system-packages cloakbrowser
# Download the binary and expose it at a stable path
RUN HOME=/opt python3 -c "from cloakbrowser.download import ensure_binary; import os; \
p=ensure_binary(); os.makedirs('/opt/cloakbrowser', exist_ok=True); \
os.path.lexists('/opt/cloakbrowser/chrome') or os.symlink(p,'/opt/cloakbrowser/chrome')" \
&& chmod -R a+rX /opt/.cloakbrowser /opt/cloakbrowser
# Point the node's bundled chromedriver at our binary
ENV SE_BROWSER_BINARY_LOCATION=/opt/cloakbrowser/chrome
USER seluser
services:
selenium-hub:
image: selenium/hub:4.44.0
ports: ["4444:4444"]
networks: [grid-network]
cloak-node:
build: { context: ., dockerfile: Dockerfile.cloak-node }
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
networks: [grid-network]
networks: { grid-network: { driver: bridge } }Client — note you do not set import random
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
opts = Options()
opts.add_argument("--no-sandbox")
opts.add_argument(f"--fingerprint={random.randint(10000, 99999)}")
opts.add_argument("--fingerprint-platform=windows")
opts.add_argument("--headless=new")
driver = webdriver.Remote(command_executor="http://selenium-hub:4444", options=opts)
driver.get("https://example.com")
print(driver.execute_script(
"return {webdriver: navigator.webdriver, platform: navigator.platform, ua: navigator.userAgent}"))
driver.quit()When we ran this, the node (on Linux) reported Honest caveats:
Let us know if this works for you, or if you want the same setup for the standalone (non-Grid) image. |
Beta Was this translation helpful? Give feedback.
Thanks for the detailed question, and thanks @salvador-castro for the solid answer — it's accurate. We actually built and ran this on a real Grid to confirm the snippet works, so here's a tested setup.
One correction first: the free binary is now Chromium 146 (not 145), and Pro is 148. That matters because ChromeDriver enforces a major-version match — your Grid node's driver major must equal the binary's major.
The cleanest path is to base your node on the official
selenium/node-chrometag whose Chromium major matches our binary. That image already ships a matching ChromeDriver and all the Chrome runtime deps — you just swap in our binary via theSE_BROWSER_BINARY_LOCATIONenv var (no han…