using OpenQA.Selenium.Chrome;
using System.Collections.Generic;
public static void Main()
ChromeDriver driver = new ChromeDriver();
string page_to_screenshot = "https://google.com";
driver.Url = page_to_screenshot;
Dictionary<string, Object> metrics = new Dictionary<string, Object>();
metrics["width"] = driver.ExecuteScript("return Math.max(window.innerWidth,document.body.scrollWidth,document.documentElement.scrollWidth)");
metrics["height"] = driver.ExecuteScript("return Math.max(window.innerHeight,document.body.scrollHeight,document.documentElement.scrollHeight)");
metrics["deviceScaleFactor"] = (double)driver.ExecuteScript("return window.devicePixelRatio");
metrics["mobile"] = driver.ExecuteScript("return typeof window.orientation !== 'undefined'");
driver.ExecuteChromeCommand("Emulation.setDeviceMetricsOverride", metrics);
string path_to_save_screenshot = @"C:/temp/temp.png";
driver.GetScreenshot().SaveAsFile(path_to_save_screenshot, ScreenshotImageFormat.Png);
driver.ExecuteChromeCommand("Emulation.clearDeviceMetricsOverride", new Dictionary<string, Object>());