0

I have a problem with running my selenium test in headless mode with some specific profile (with extensions). without headless, the script is working file (with specific profile), but with the headless mode, it is picking default profile which resulted in the failure of the script.

Tried some ways to solve this issue, but nothing worked.

  1. chromeOptions.setAcceptInsecureCerts(true); chromeOptions.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true); chromeOptions.setCapability(CapabilityType.ACCEPT_INSECURE_CERTS, true);

  2. chromeOptions.addArguments("--remote-debugging-port=23456"); - this resulted in error at this port.

    code setup for starting chrome browser in headless mode.

    chromeOptions.setExperimentalOption("excludeSwitches", 
    Arrays.asList("disable-sync", "enable-logging"));
    chromeOptions.addArguments("--enable-sync");
    chromeOptions.addArguments("--disable-logging");
    chromeOptions.addArguments("--no-sandbox");
    chromeOptions.addArguments("--disable-dev-shm-usage");
    
    chromeOptions.addArguments("--headless");
    chromeOptions.addArguments("--disable-gpu");
    chromeOptions.addArguments("--window-size=1280,800");
    chromeOptions.addArguments("--allow-insecure-localhost");
    chromeOptions.addArguments("--remote-debugging-port=45447");
    
    chromeOptions.setAcceptInsecureCerts(true);
    chromeOptions.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
    chromeOptions.setCapability(CapabilityType.ACCEPT_INSECURE_CERTS, true);
    
Taimoor Suleman
  • 1,588
  • 14
  • 29
Raj
  • 21
  • 6
  • Browser not running in `headless` or what? – hrdkisback Aug 20 '19 at 07:17
  • Browser is running with default profile in headless mode, I am expecting it to run with specific profile with chrome extension. I think here the issue is with extension and extension combination – Raj Aug 20 '19 at 07:58
  • To add the extension you need to add this `chromeOptions.addExtensions(new File(extensionFilepath));` – hrdkisback Aug 20 '19 at 08:53

1 Answers1

1

Adding extensions are not supported with headless run. So, used "Xvfb" virtual frame buffer to mock the chrome UI. Remove "--headless" while starting the browser instance.

Raj
  • 21
  • 6