I am trying to create some automation tests for the login feature, with goal users can enter the dashboard code after login.
I use java + selenium + cucumber.
I can run the test and get passed result when on UI mode (normal mode / not on headless mode). But when I am switching to headless mode I get an error and the automation cannot enter the dashboard.
This is my chrome option on my code
//use it when run on linux
System.setProperty("webdriver.chrome.driver","/usr/bin/chromedriver");
//use it when run on mac
//System.setProperty("webdriver.chrome.driver","/usr/local/bin/chromedriver");
ChromeOptions options = new ChromeOptions();
options.setExperimentalOption("useAutomationExtension", false);
options.addArguments(
"--verbose",
"--headless",
"--incognito",
"--test-type",
"--window-size=1920,1080",
"--start-maximized",
"--disable-web-security",
"--disable-gpu",
"--disable-popup-blocking",
"--disable-dev-shm-usage",
"--disable-extensions",
"--disable-infobars",
"--allow-running-insecure-content",
"--allow-insecure-localhost",
"--ignore-certificate-errors",
"--no-sandbox"
);
//use it when run in headless
driver = new ChromeDriver(options)
I added a large window size, add some arguments option for chrome headless but it still has a problem when using headless mode.
this is my repository https://gitlab.com/hanatakaruki/loginproblem.git
you can clone it and test on your local, please test UI/normal mode first then try headless mode.
thank you