0

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

  • Can you post the exact error in logs that you are receiving? – zookastos Jan 28 '20 at 23:27
  • @zookastos sure, this my error logs https://pastebin.com/6tQx49FE, you may think I should change the xpath for verifying dashboard page, I have changed with all xpath on all element in dashboard page, except logo/image because on login page it have the same image like that, and why I say it stuck on login page, because when my test failure it will capture the screenshot, and I see it stuck on login page – Ahmad Ubaidillah Jan 28 '20 at 23:32
  • I know this is not directly answering your question but have you tried https://www.0browser.com ? They offer Headless Chrome and it just works. It's free – Raha Jan 29 '20 at 05:40

0 Answers0