title: Selenium Python test against Selenium grid created from SeleniumHQ Docker images
body: <h2>In brief</h2>
  
  <p>How to run Python Selenium tests properly against Selenium Grid container created from SeleniumHQ Docker images?</p>
  
  <p>I also asked on SeleniumHQ here
  <a href="https://github.com/SeleniumHQ/docker-selenium/issues/521" rel="nofollow noreferrer">https://github.com/SeleniumHQ/docker-selenium/issues/521</a></p>
  
  <h2>The error &amp; log</h2>
  
  <ul>
  <li><p><a href="https://github.com/namgivu/selenium-docker-sandbox/blob/master/error_note/00.console-error.txt" rel="nofollow noreferrer">00 - the console error</a></p></li>
  <li><p><a href="https://github.com/namgivu/selenium-docker-sandbox/blob/master/error_note/01.hub-log.txt" rel="nofollow noreferrer">01 - the hub log</a></p></li>
  <li><p><a href="https://github.com/namgivu/selenium-docker-sandbox/blob/master/error_note/02c.node-log-CH.txt" rel="nofollow noreferrer">02c - the chrome node log</a></p></li>
  <li><p><a href="https://github.com/namgivu/selenium-docker-sandbox/blob/master/error_note/02f.node-log-FF.txt" rel="nofollow noreferrer">02f - the firefox node log</a></p></li>
  </ul>
  
  <h2>Full details</h2>
  
  <p>I've tried <a href="https://www.google.com.vn/search?q=fail+to+execute+selenium+python+test+against+selenium+grid+created+from+SeleniumHQ+docker+images&amp;oq=fail+to+execute+selenium+python+test+against+selenium+grid+created+from+SeleniumHQ+docker+images&amp;aqs=chrome..69i57.90454j0j7&amp;sourceid=chrome&amp;ie=UTF-8" rel="nofollow noreferrer">this web search</a> and <a href="https://stackoverflow.com/search?q=Selenium+python+test+against+selenium+grid+created+from+SeleniumHQ+docker+images">similar search on our site</a> and found none useful.</p>
  
  <p><strong>OK with standalone</strong></p>
  
  <p>I've succeeded in running <a href="https://github.com/namgivu/selenium-docker-sandbox/blob/master/s02a2_tiny_test_standalone.py" rel="nofollow noreferrer">this simple test</a> against the <a href="https://github.com/SeleniumHQ/docker-selenium#standalone-chrome-and-firefox" rel="nofollow noreferrer">standalone selenium grid for Chrome and Firefox</a> </p>
  
  <p>- start the grid <a href="https://github.com/namgivu/selenium-docker-sandbox/blob/master/s01b_start_selenium_standalone_grid.sh" rel="nofollow noreferrer">view standalone grid create script</a></p>
  
  <pre><code>docker run -d -p 4445:4444 -v /dev/shm:/dev/shm selenium/standalone-chrome:3.4.0-einsteinium
  docker run -d -p 4446:4444 --shm-size 2g selenium/standalone-firefox:3.4.0-einsteinium
  </code></pre>
  
  <p>- run test <a href="https://github.com/namgivu/selenium-docker-sandbox/blob/master/s02a2_tiny_test_standalone.py" rel="nofollow noreferrer">view standalone test</a></p>
  
  <pre><code>#!/usr/bin/env python2.7
  
  SELENIUM_HUB_CH = 'http://localhost:4445/wd/hub' #hub created at file 's01b_start_selenium_standalone_grid.sh'
  SELENIUM_HUB_FF = 'http://localhost:4446/wd/hub' #hub created at file 's01b_start_selenium_standalone_grid.sh'
  
  #region webdriver loading
  from selenium import webdriver
  from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
  driverCH = webdriver.Remote(
    command_executor=SELENIUM_HUB_CH,
    desired_capabilities=DesiredCapabilities.CHROME,
  )
  driverFF = webdriver.Remote(
    command_executor=SELENIUM_HUB_FF,
    desired_capabilities=DesiredCapabilities.FIREFOX,
  )
  #endregion webdriver loading
  
  for driver in [driverCH, driverFF]:
    driver.get('http://www.google.com')
    print(driver.title)
  </code></pre>
  
  <p><strong>But FAIL with hub+node grid</strong></p>
  
  <p>Though I failed to run <a href="https://github.com/namgivu/selenium-docker-sandbox/blob/master/s02a1_tiny_test.py" rel="nofollow noreferrer">that simple test</a> against the <a href="https://github.com/SeleniumHQ/docker-selenium#selenium-grid-hub-and-nodes" rel="nofollow noreferrer">hub+node selenium grid</a></p>
  
  <p>- start the grid <a href="https://github.com/namgivu/selenium-docker-sandbox/blob/master/s01a_start_selenium_grid.sh" rel="nofollow noreferrer">view hub+node creation script</a></p>
  
  <pre><code>docker run -d -p 4444:4444 --name selenium-hub selenium/hub:3.4.0-einsteinium
  docker run -d --link selenium-hub:hub selenium/node-chrome:3.4.0-einsteinium
  docker run -d --link selenium-hub:hub selenium/node-firefox:3.4.0-einsteinium
  </code></pre>
  
  <p>- run the test <a href="https://github.com/namgivu/selenium-docker-sandbox/blob/master/s02a1_tiny_test.py" rel="nofollow noreferrer">view simple test</a></p>
  
  <pre><code>#!/usr/bin/env python2.7
  
  SELENIUM_HUB = 'http://localhost:4444/wd/hub'
  
  from selenium import webdriver
  from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
  driver = webdriver.Remote(
    command_executor=SELENIUM_HUB,
    desired_capabilities=DesiredCapabilities.CHROME,
  )
  
  driver.get('http://www.google.com')
  print(driver.title)
  </code></pre>
  
  <p><strong>The question</strong></p>
  
  <p>I am interested in testing against Selenium grid containers i.e. the hub+node container created from <a href="https://github.com/SeleniumHQ/docker-selenium#selenium-grid-hub-and-nodes" rel="nofollow noreferrer">these Docker images</a>.</p>