Thank you.
You mean I should two versions of the configuration. one for GitLab (with headLess mode) and one for IDE (without headLess mode)?
At least at first, while you are still setting it up, you should deactivate the headless mode in the IDE.
When you are sure it works everytime, you can try setting-up the headless mode.
Finally, setting-up gitlab-ci.
Also, regarding the following line:
driver.manage().window().maximize();
It is recommended to maximize the Google Chrome browser through ChromeOptions
class as follows:
options.addArguments("start-maximized");
In your code, that may look like this:
WebDriverManager.chromedriver().setup();
ChromeOptions options = new ChromeOptions();
options.setHeadless(true);
options.addArguments('start-maximized');
driver = new ChromeDriver(options);