### Question:
HeadlessChromeCapabilitiesBuilder extends ChromeCapabilitiesBuilder { @Override @SuppressWarnings("unchecked") public DesiredCapabilities getCapabilities(DesiredCapabilities capabilities) { super.getCapabilities(capabilities); Map<String, Object> existing = (Map<String, Object>) capabilities.getCapability(ChromeOptions.CAPABILITY); List<String> args = Lists.newArrayList(); if (existing != null && existing.containsKey("args")) { args.addAll((List<String>) existing.get("args")); } args.remove("--headless"); args.add("--headless"); args.add("--disable-gpu"); existing.put("args", ImmutableList.copyOf(args)); return capabilities; }  @Override @SuppressWarnings("unchecked") DesiredCapabilities getCapabilities(DesiredCapabilities capabilities);  }### Answer:
@Test public void testIsHeadless(ITestContext ctx) { LocalConfig lc = new LocalConfig(); lc.setConfigProperty(Config.ConfigProperty.BROWSER_RUN_HEADLESS, "false"); ConfigManager.addConfig(ctx.getCurrentXmlTest().getName(), lc); DesiredCapabilities capabilities = new HeadlessChromeCapabilitiesBuilder().getCapabilities(new DesiredCapabilities()); assertNotNull(capabilities.getCapability(ChromeOptions.CAPABILITY)); Map<String, List<String>> chromeOptionsMap = (Map<String, List<String>>) capabilities.getCapability(ChromeOptions.CAPABILITY); assertTrue(chromeOptionsMap.containsKey("args")); assertTrue(chromeOptionsMap.get("args").contains("--headless")); }