If I understand well, now, your tests are working well in your IDE, in both windowed and headless mode?
And in gitlab-ci, you do not have a "Unable to load browser" error anymore, but the "Unable to wait and click" one?
If so, I can see two reason for that:
- your test is not idempotent: the state of your page changes over time. To debug this, try to take a screenshot and to retrieve it as an artifact in gitlab-ci
- your app needs more time to properly load its content, and in gitlab-ci, docker images are not powerfull enough to process it in time. Try to globally increase the timeouts before a test is considered failing
To make sure the whole thing is properly working and to distinguish issues in tests from issues while trying to execute the tests, you can try to add a really simple "Hello world" test in your test-suite, which load the simplest possible page and check it is displayed by the browser.
If that test pass, you know that Selenium is properly set-up in the CI.
If not, you can continue working on setting it up.