Reputation: 11
I want to use chromedriver headless instead of phantomjs. For phantomjs , I was able to provide the ssl certificate and key paths as commandline arguments. as below. How do I provide certificate and key paths as command line arguments for headless chromedriver?
ImmutableMap<String, String> commandLineArguments = ImmutableMap.<String, String>builder()
.put("ssl-protocol", "any")
.put("ssl-client-certificate-file", certificatePath)
.put("ssl-client-key-file", certificateKeyPath)
.put("ssl-client-key-passphrase", "webpass").build();
String[] params = commandLineArguments.entrySet().stream()
.map(e -> String.format("--%s=%s", e.getKey(), e.getValue()))
.collect(Collectors.toList())
.toArray(new String[0]);
cap.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
cap.setCapability(PhantomJSDriverService.PHANTOMJS_CLI_ARGS, params);
Upvotes: 0
Views: 415
Reputation: 1996
WebDriver driver;
case WebDriverType.CHROME:
WebDriverManager.chromedriver().setup();
ChromeOptions cOptions = new ChromeOptions();
cOptions.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
cOptions.setAcceptInsecureCerts(true);
// this isthe option to run chrome in headless mode
cOptions.setHeadless(true);
cOptions.addArguments("--ignore-certificate-errors");
cOptions.addArguments("disable-infobars");
driver = new ChromeDriver(cOptions);
break;
You can pass this way as well to run chrome in headless mode.
Upvotes: 1