static void Main(string[] args) { //https://chromedevtools.github.io/devtools-protocol/tot/Page/#method-printToPDF var driverOptions = new ChromeOptions(); driverOptions.AddArgument("headless"); using (ChromeDriver driver = new ChromeDriver(driverOptions)) { driver.Navigate().GoToUrl("http://*****:*****@equals = driver.ExecuteScript("return document.readyState").Equals("complete"); Dictionary <string, object> printOutput = driver.ExecuteChromeCommandWithResult("Page.printToPDF", printOptions) as Dictionary <string, object>; byte[] pdf = Convert.FromBase64String(printOutput["data"] as string); File.WriteAllBytes("magazine.pdf", pdf); } }
public void TestMethod1() { ChromeOptions options = new ChromeOptions(); var chromeDriverService = ChromeDriverService.CreateDefaultService(@"c:\bom"); chromeDriverService.HideCommandPromptWindow = true; chromeDriverService.SuppressInitialDiagnosticInformation = true; options.AddArgument("log-level=3"); var driver = new ChromeDriver(chromeDriverService, options); var result = driver.ExecuteChromeCommandWithResult("monitorEvents", new Dictionary <string, object>() { { "", "" } }); Assert.IsNotNull(driver); }