0

For development I want to run my tests locally and selenium using selenium hub.

  hub:
    image: selenium/hub
    environment:
      GRID_BROWSER_TIMEOUT: '300'
    ports:
      - "4444:4444"
  firefox_node_1:
    image: selenium/node-firefox-debug
    depends_on:
      - hub
    environment:
      HUB_HOST: hub
    ports:
      - "5900:5900"

In my test I use:

class SimpleTestCase(StaticLiveServerTestCase):

    def setUp(self):
        super(SimpleTestCase, self).setUp()

        self.browser = webdriver.Remote(command_executor=f'http://localhost:4444/wd/hub',
                                        desired_capabilities=DesiredCapabilities.FIREFOX)


    def tearDown(self):
        self.browser.quit()
        super(SimpleTestCase, self).tearDown()

    def test_mainpage(self):
        self.browser.get(self.live_server_url)

But in this case I get network error because firefox node do not see my localhostpc

I tried to set host to 0.0.0.0

class SimpleTestCase(StaticLiveServerTestCase):
    host = '0.0.0.0'

And of course container do not see my pc, is there a way to do this without dockerize my Django app

Arti
  • 7,356
  • 12
  • 57
  • 122
  • I don't think this is a duplicated question. Anyway, could you try with `http://hub:4444` instead? Inside docker-compose, services communicate together via service name (or IP if you want but I refer service name, easier). Directly connect firefox node to selenium hub inside docker-compose. – Toan Quoc Ho Oct 11 '19 at 16:23
  • `http://hub:4444` is not working because django test is running on my pc and in docker it try to open localhost but docker container do not have access to my pc. So I need to share it some how. I read about bridged network – Arti Oct 11 '19 at 16:53
  • I see. So your test scripts are not run inside that compose. So your test script is trying to connect to the selenium hub but inside the selenium hub, there is no browser node right? Have you try with `HUB_PORT_4444_TCP_ADDR=hub` and `HUB_PORT_4444_TCP_PORT=4444` as environment variable for firefox node? – Toan Quoc Ho Oct 11 '19 at 20:39

0 Answers0