If I am running my testng xml locally it works fine in both headless or without however, when I am running it with jenkins it is giving me error in case of not headless
if (Utility.fetchConfigPropertyValue("browserName", config_Property_File_Path).toString()
.equalsIgnoreCase("chrome")) {
System.setProperty("webdriver.chrome.driver", "../ams-common/Drivers/chromedriver");
ChromeOptions options = new ChromeOptions();
options.setHeadless(true);
options.setBinary("/usr/bin/google-chrome-stable");
options.addArguments("disable-infobars"); // disabling infobars
options.addArguments("disable-extensions"); // disabling extensions
options.addArguments("disable-dev-shm-usage"); // overcome limited resource problems
options.addArguments("no-sandbox"); // Bypass OS security model
driver = new ChromeDriver(options);
}
Error on Jenkins
org.openqa.selenium.WebDriverException: unknown error: Chrome failed to start: exited abnormally. (unknown error: DevToolsActivePort file doesn't exist) (The process started from chrome location /usr/bin/google-chrome-stable is no longer running, so ChromeDriver is assuming that Chrome has crashed.)
Kindly note I have checked related question but did not resolve my issue.