ChromeOptions options = new ChromeOptions();
options.setExperimentalOption("useAutomationExtension", false);
options.addArguments("--headless", "--window-size=1920,1200","--ignore-certificate-errors");
DesiredCapabilities crcapabilities = DesiredCapabilities.chrome();
crcapabilities.setCapability(ChromeOptions.CAPABILITY, options);
crcapabilities.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
crcapabilities.setCapability(CapabilityType.ACCEPT_INSECURE_CERTS, true);
System.setProperty(ChromeDriverService.CHROME_DRIVER_LOG_PROPERTY, "C:\temp\chrome\chromedriver.log");
System.setProperty(ChromeDriverService.CHROME_DRIVER_EXE_PROPERTY, "C:\temp\chrome\chromedriver.exe");
ChromeDriverService service = null;
try {
service = new ChromeDriverService.Builder()
.usingAnyFreePort()
.withVerbose(true)
.build();
service.start();
} catch (IOException e) {
e.printStackTrace();
}
RemoteWebDriver driver = new RemoteWebDriver(service.getUrl(),crcapabilities);
driver.get("https://www.intellipaat.com/");
System.out.println(driver.getPageSource());
driver.quit();