instrumentisto / geckodriver-docker-image

geckodriver Docker image
https://firefox-source-docs.mozilla.org/testing/geckodriver
Other
19 stars 5 forks source link

Support --host parameter to use container in pipeline #5

Closed timvol closed 1 year ago

timvol commented 1 year ago

At first, thank you very much for maintaining these containers! I'm trying to use this image in my Gitlab CI/CD-Pipeline as service. Unfortunately I cannot use it because it says:

Could not open connection: Curl error thrown for http POST to /session with params: {"capabilities":{"firstMatch":[{"browserName":"firefox","moz:firefoxOptions":{"prefs":{"reader.parse-on-load.enabled":false,"devtools.jsonview.enabled":false}}}]},"desiredCapabilities":{"browserName":"firefox","platform":"ANY","moz:firefoxOptions":{"prefs":{"reader.parse-on-load.enabled":false,"devtools.jsonview.enabled":false}},"prefs":{"devtools.console.stdout.content":true},"log":{"level":"trace"},"args":["-headless"]}}
Failed to connect to geckodriver port 4444: Connection refused

After short googling regarding this error it seems that the error is related to https://github.com/mozilla/geckodriver/issues/2017

So it seems that the problem is the --host. The geckodriver listens to 127.0.0.1:4444 per default but since other containers are trying to connect to it in the pipeline, it refuses the connection. Would it be possible to add an environment variable (e.g. HOST) or similar that allows to specify the --host parameter or maybe an env parameter ALLOW_ALL which adds --host "::1"?

tyranron commented 1 year ago

@timvol why you don't just specify the desired address via CLI options?

This is how we use this image in our E2E tests on GitLab CI (from docker-compose.yaml):

  webdriver-firefox:
    container_name: ${COMPOSE_PROJECT_NAME}-webdriver-firefox
    image: ghcr.io/instrumentisto/geckodriver:latest
    command:
      - --binary=/opt/firefox/firefox
      - --host=0.0.0.0
      - --port=4444
      - --allow-hosts=localhost
      - --log=debug
    ports:
      - "4444:4444"  
    shm_size: 512m
timvol commented 1 year ago

@tyranron I was finally able to solve it by adding the command flag to my Gitlab-CI, but the interesting thing is that it seems that it doesn't find any buttons, links or texts where it's necessary to scroll down. In my previous tests (where I installed Firefox + geckodriver directly in the container) it was working. I used Firefox 102.9.0esr and Geckodriver 0.32.2 previously. Any idea why it's not working anymore?

tyranron commented 1 year ago

@timvol nope, sorry, no idea with that. I doubt this Docker related. Maybe some parameters of WebDriver session initialization require tuning, but doesn't seem so. Try to debug and get some logs from what's going on in browser.