Using chrome devtools protocol in selenium chrome docker containers

484 views
Skip to first unread message

Bimal Viswam

unread,
Nov 7, 2019, 1:14:39 AM11/7/19
to Selenium Users
Hello, 

I was able to get the chrome dev tools protocol and my webdriver js library communicate in my local. The goal was to intercept the request and it is working fine . The way I achieved is as below. Now , I am trying to do the same with a docker container which was spun up using chrome-debug docker image. Even though, I get AddressString  I am not able to connect to that and getting a connect ECONNREFUSED 127.0.0.1:38243  Any suggestions on how to resolve this?  Do I need to have some extra configuration to achieve this?  I have copied my docker-compose that I use to create grid. Any help is appreciated.



version"3.7"
services:
  selenium_hub_ix:
    container_nameselenium_hub_ix
    imageselenium/hub:latest
    environment:
      SE_OPTS"-port 4445"
    ports:
      - 4445:4445
  chrome_ix:
    imageselenium/node-chrome-debug:latest
    container_namechrome_node_ix
    depends_on:
      - selenium_hub_ix
    ports:
      - 5905:5900
      - 5903:5555
      - 9222:9222
    environment:
      - no_proxy=localhost
      - HUB_PORT_4444_TCP_ADDR=selenium_hub_ix
      - HUB_PORT_4444_TCP_PORT=4445
      - NODE_MAX_INSTANCES=5
      - NODE_MAX_SESSION=5
      - TZ=America/Chicago
    volumes:
      - /dev/shm:/dev/shm




 this.driver = await new webDriver.Builder().forBrowser("chrome").build();
      let session = await this.driver.session_
      let debuggerAddress = await session.caps_.map_.get("goog:chromeOptions").debuggerAddress;
      let AddressString = debuggerAddress.split(":");
      const protocol = await CDP({
         port: AddressString[1]
      });
      const {
         Fetch
      } = protocol;

      await Fetch.enable({
         patterns: [{
            urlPattern: "*api*",
            resourceType: "XHR"
         }]
      });

      await Fetch.requestPaused(async ({
         request
      }) => {
         console.log(request)

      })

Bimal Viswam

unread,
Nov 7, 2019, 10:52:31 AM11/7/19
to Selenium Users
Just to make sure   

When I am hitting grid, 

I am using below line to create the driver 

 this.driver = await new webDriver.Builder().usingServer("http://localhost:4445").withCapabilities(webDriver.Capabilities.chrome()).build();

Patrick Bressan Bremm

unread,
Jan 24, 2020, 10:16:37 PM1/24/20
to Selenium Users
Hii,

Try replace localhost for container name docker. 
Reply all
Reply to author
Forward
0 new messages