Can someone assist how to solve this issue (if possible to be solved)?
I am using DevTools for getting necessary token (in all automation tests). Tests are written in Java (Selenium 4.16.1) In order to have them run on pipeline, must be in headless mode and in incognito mode, too. But throws error: java.awt.AWTException: headless environment
Tried a lot of options in Chrome, but without any success. Chrome browser class looks like this:
ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.addArguments("--disable-extensions");
chromeOptions.addArguments("--enable-application-cache");
chromeOptions.addArguments("--allow-running-insecure-content");
chromeOptions.addArguments("--no-sandbox");
chromeOptions.addArguments("--enable-automation");
chromeOptions.addArguments("--ignore-certificate-errors");
chromeOptions.addArguments("--remote-allow-origins=*");
chromeOptions.addArguments("--disable-dev-shm-usage");
chromeOptions.addArguments("--disable-gpu");
chromeOptions.addArguments("--remote-debugging-port=3222");
chromeOptions.addArguments("--disable-infobars");
String incognito = System.getProperty("incognito", "false");
if (incognito.equalsIgnoreCase("true")) {
chromeOptions.addArguments("--incognito");
}
String pathToDownl = System.getProperty("user.home") + "\\" + Constants.
$string("download.location");
HashMap<String, Object> chromePre = new HashMap<String, Object>();
chromePre.put("profile.default_content_settings.popups", 0);
chromePre.put("download.prompt_for_download", false);
chromePre.put("download.default_directory", pathToDownl);
chromePre.put("profile.content_settings.exceptions.automatic_downloads.*.setting", 1);
chromePre.put("safebrowsing.enabled", false);
chromeOptions.setExperimentalOption("prefs", chromePre);
//System.out.println(pathToDownl);
if ($boolean("enableProxy")==true){
chromeOptions.setCapability("proxy", setProxy());
}