VIC Containers Running Selenium Report "org.openqa.selenium.WebDriverException: connection refused"
search cancel

VIC Containers Running Selenium Report "org.openqa.selenium.WebDriverException: connection refused"


Article ID: 340132


Updated On:


VMware vSphere ESXi


When running Selenium Grid WebDriver test, the driver reports a stack trace with "Caused by: org.openqa.selenium.WebDriverException: connection refused". Reviewing the output of "docker -H VCH_IP_FQDN:2376 --tls logs <Container_Name_ID>" Similar to the following is seen. 
16:09:24.743 INFO - The node is registered to the hub and ready to use
2018-03-14 16:15:20.489:INFO:osjshC.ROOT:qtp436546048-12: org.openqa.selenium.remote.server.WebDriverServlet-3ba9ad43: Initialising WebDriverServlet
16:15:20.535 INFO - Found handler: org.openqa.selenium.remote.server.commandhandler.BeginSession@2258a381
16:15:20.541 INFO - /session: Executing POST on /session (handler: BeginSession)
16:15:20.669 INFO - Capabilities are: Capabilities {acceptInsecureCerts: true, browserName: firefox, version: }
16:15:20.673 INFO - Capabilities {acceptInsecureCerts: true, browserName: firefox, version: } matched class org.openqa.selenium.remote.server.ServicedSession$Factory (provider: org.openqa.selenium.firefox.GeckoDriverService)
1521044120746   geckodriver     INFO    geckodriver 0.19.1
1521044120752   geckodriver     INFO    Listening on
1521044121064   mozrunner::runner       INFO    Running command: "/usr/bin/firefox" "-marionette" "-profile" "/tmp/rust_mozprofile.lZOama6uW0oN"
Error: Access was denied while trying to open files in your profile directory.
(firefox:350): dconf-CRITICAL **: unable to create directory '/root/.cache/dconf': Permission denied.  dconf will not work properly.

When deploying the debug image "selenium/node-firefox-debug" the VNC console will not connect to the container. 

Note: The preceding log excerpts are only examples. Date, time, and environmental variables may vary depending on your environment. 


VMware vSphere Integrated Containers 1.x


The home environment path may not be set for the non-root user used within the container image.


Set the HOME environment path manually.

To do this using the docker client add
-e HOME=/home/seluser to the create or run command. Below is an example of how to do this when using "docker create" to create the container first.

docker -H VCH_IP_FQDN:2376 --tls create -e HOME=/home/seluser -e HUB_PORT_4444_TCP_ADDR=hub -e 
HUB_PORT_4444_TCP_PORT=4444 -e NODE_MAX_INSTANCES=5 -e NODE_X_SESSION=3 -e GRID_MAX_SESSION=10 -it --name FireFoxNodeExample selenium/node-firefox

To do this using docker compose the docker-compose.yml will need the FireFox environment section changed to include - HOME=/home/seluse like shown in the example below. (Note docker-compose.yml is sensitive to the leading space count for each line.)

    cpu_count: 1
    image: "selenium/node-firefox"
      - HOME=/home/seluser
      - HUB_PORT_4444_TCP_ADDR=hub
      - HUB_PORT_4444_TCP_PORT=4444
      - NODE_X_SESSION=3 

There is also an example selenium docker-compose.yml for use with VIC located here

Additional Information

More information about running Selenium Grid can be found at Running Selenium Grid on vSphere with vSphere Integrated Containers 

A tracking issue is also available in GitHub at Set environment variables from non-root user profiles #7536