Exemplo n.º 1
0
 /// <summary>Take screen-shot and save it to file.</summary>
 /// <param name="webDriver">WebDriver capable of taking screen-shots</param>
 /// <param name="imagePath">Screen-shot file path</param>
 /// <param name="imageFormat">Image format in which screen-shot will be saved</param>
 public static void SavePageImage(
     this ITakesScreenshot webDriver,
     string imagePath,
     ScreenshotImageFormat imageFormat)
 {
     webDriver.GetScreenshot().SaveAsFile(imagePath, imageFormat);
 }
Exemplo n.º 2
0
        public string TakesScreenshotWithDate(string Path, string FileName, ScreenshotImageFormat Format)
        {
            ScreenCounter++; //Updates the number of screenshots that we took during the execution

            StringBuilder TimeAndDate = new StringBuilder(DateTime.Now.ToString());

            TimeAndDate.Replace("/", "_");
            TimeAndDate.Replace(":", "_");

            //Remember that we cannot save a file with '/' Or ':', but we still need a unique identifier, Therefore, we will make this simple replace.

            //    Before: 12 / 06 / 2015 14:54:55
            //After: 12_06_2015 14_54_55

            DirectoryInfo Validation     = new DirectoryInfo(Path); //System IO object
            var           ScreenShotPath = Path + ScreenCounter.ToString() + "." + FileName + TimeAndDate.ToString() + "." +
                                           Format;

            if (Validation.Exists == true) //Capture screen if the path is available
            {
                ((ITakesScreenshot)driver).GetScreenshot().SaveAsFile(ScreenShotPath, Format);
            }
            else //Create the folder and then Capture the screen
            {
                Validation.Create();
                ((ITakesScreenshot)driver).GetScreenshot().SaveAsFile(ScreenShotPath, Format);
            }

            return(ScreenShotPath);
        }
 public static void TakeScreenshot(this IWebDriver driver, string pathToFile = path,
                                   ScreenshotImageFormat format = ScreenshotImageFormat.Png)
 {
     ((ITakesScreenshot)driver)
     .GetScreenshot()
     .SaveAsFile(pathToFile, format);
 }
Exemplo n.º 4
0
        private static ImageFormat ConvertScreenshotImageFormat(ScreenshotImageFormat format)
        {
            ImageFormat returnedFormat = ImageFormat.Png;

            switch (format)
            {
            case ScreenshotImageFormat.Jpeg:
                returnedFormat = ImageFormat.Jpeg;
                break;

            case ScreenshotImageFormat.Gif:
                returnedFormat = ImageFormat.Gif;
                break;

            case ScreenshotImageFormat.Bmp:
                returnedFormat = ImageFormat.Bmp;
                break;

            case ScreenshotImageFormat.Tiff:
                returnedFormat = ImageFormat.Tiff;
                break;
            }

            return(returnedFormat);
        }
Exemplo n.º 5
0
        public void TestTakeScreenshot()
        {
            using (var xrmBrowser = new XrmBrowser(TestSettings.Options))
            {
                xrmBrowser.LoginPage.Login(_xrmUri, _username, _password);
                xrmBrowser.GuidedHelp.CloseGuidedHelp();

                ScreenshotImageFormat fileFormat = ScreenshotImageFormat.Tiff;  // Image Format -> Png, Jpeg, Gif, Bmp and Tiff.

                xrmBrowser.TakeWindowScreenShot("D:\\Screenshot" + "." + fileFormat, fileFormat);

                xrmBrowser.ThinkTime(500);
                xrmBrowser.Navigation.OpenSubArea("Sales", "Accounts");

                xrmBrowser.ThinkTime(2000);
                xrmBrowser.Grid.SwitchView("Active Accounts");

                xrmBrowser.ThinkTime(1000);
                xrmBrowser.CommandBar.ClickCommand("New");

                xrmBrowser.ThinkTime(4000);
                xrmBrowser.Entity.SetValue("name", "Test API Account");
                xrmBrowser.Entity.SetValue("telephone1", "555-555-5555");
                xrmBrowser.Entity.SetValue("websiteurl", "https://easyrepro.crm.dynamics.com");

                xrmBrowser.CommandBar.ClickCommand("Save & Close");
                xrmBrowser.ThinkTime(2000);
            }
        }
Exemplo n.º 6
0
        private static void TakeScreenshotPrivate(string strFilename)
        {
            var objRectangle = Screen.PrimaryScreen.Bounds;
            var objBitmap    = new Bitmap(objRectangle.Right, objRectangle.Bottom);
            var objGraphics  = System.Drawing.Graphics.FromImage(objBitmap);
            var hdcSrc       = GetDC(0);
            var hdcDest      = objGraphics.GetHdc();

            BitBlt(hdcDest.ToInt32(), 0, 0, objRectangle.Right, objRectangle.Bottom, hdcSrc, 0, 0, 0xcc0020);
            objGraphics.ReleaseHdc(hdcDest);
            ReleaseDC(0, hdcSrc);

            var strFormatExtension = ScreenshotImageFormat.ToString().ToLower();

            if (Path.GetExtension(strFilename) != ("." + strFormatExtension))
            {
                strFilename = strFilename + "." + strFormatExtension;
            }

            if (strFormatExtension == "jpeg")
            {
                BitmapToJpeg(objBitmap, strFilename, 80L);
            }
            else
            {
                objBitmap.Save(strFilename, ScreenshotImageFormat);
            }

            _strScreenshotFullPath = strFilename;
        }
Exemplo n.º 7
0
        /// <summary>
        /// Take screenshot of the currently open page.
        /// </summary>
        /// <param name="screenshotFileName">Screenshot's full name.</param>
        /// <param name="format">Image format.</param>
        /// <remarks>There is a known issue with taking screenshots in IE:
        /// https://github.com/seleniumhq/selenium-google-code-issue-archive/issues/7256#issuecomment-192176024
        /// Further reading:
        /// http://jimevansmusic.blogspot.com/2014/09/screenshots-sendkeys-and-sixty-four.html
        /// </remarks>
        public void SaveAs(string screenshotFileName, ScreenshotImageFormat format = ScreenshotImageFormat.Jpeg)
        {
            Logger.Exec(Logger.LogLevel.Debug, screenshotFileName, format);
            var fInfo = new FileInfo(screenshotFileName);

            // Update the name with a timestamp and a driver type.
            screenshotFileName = UpdateFilename(fInfo.Name);
            // Replace invalid path chars.
            var pathChars     = Path.GetInvalidPathChars();
            var stringBuilder = new StringBuilder(screenshotFileName);

            foreach (var item in pathChars)
            {
                stringBuilder.Replace(item, '.');
            }
            screenshotFileName = stringBuilder.ToString();
            // Create a directory if necessary.
            if (!fInfo.Directory.Exists)
            {
                fInfo.Directory.Create();
            }
            // Save the screenshot.
            _screenshot.SaveAsFile(
                $"{Path.Combine(fInfo.DirectoryName, screenshotFileName)}.{format.ToString().ToLower()}", format);
        }
Exemplo n.º 8
0
        public static void TakeScreenShot(string path, ScreenshotImageFormat format = ScreenshotImageFormat.Png)
        {
            ITakesScreenshot screenshotDriver = Instance as ITakesScreenshot;
            Screenshot       screenshot       = screenshotDriver.GetScreenshot();

            screenshot.SaveAsFile(path, format);
        }
Exemplo n.º 9
0
        /// <summary>
        /// Method used for capturing images in current window.
        /// </summary>
        /// <param name="fullPath">Path where to save file.</param>
        /// <param name="format">File format.</param>
        public void CaptureScreenshot(string fullPath, ScreenshotImageFormat format)
        {
            if (!(_webDriver is ITakesScreenshot screenshotDriver))
            {
                return;
            }
            var screenshot = screenshotDriver.GetScreenshot();

            screenshot.SaveAsFile(fullPath, format);
        }
Exemplo n.º 10
0
 public static string GetExtension(this ScreenshotImageFormat format)
 {
     if (format == ScreenshotImageFormat.Jpeg)
     {
         return(".jpg");
     }
     else
     {
         return(format.ToString().ToLower().Prepend("."));
     }
 }
Exemplo n.º 11
0
        public string TirarPrint(string nomeArquivo = "screen", ScreenshotImageFormat formatoImagem = ScreenshotImageFormat.Jpeg)
        {
            var projectPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);

            nomeArquivo = nomeArquivo + "." + formatoImagem.ToString().ToLower();
            var fileLocation = Path.Combine(projectPath, nomeArquivo);

            var ss = ((ITakesScreenshot)driver).GetScreenshot();

            ss.SaveAsFile(fileLocation, ScreenshotImageFormat.Png);
            return(fileLocation);
        }
Exemplo n.º 12
0
        public static string TakeScreenshot(string pasta)
        {
            var feature  = FeatureContext.Current.FeatureInfo.Title.ToString().Trim().Replace(" ", "");
            var scenario = ScenarioContext.Current.ScenarioInfo.Title.ToString().Trim().Replace(" ", "");

            var tempo            = string.Format("{0:dd-MM-yyyy-hh-mm-ss}", DateTime.Now);
            var dateTime         = GetCurrentDate("dd-MM-yyyy");
            var localArquivoBase = AppDomain.CurrentDomain.BaseDirectory.Replace("bin\\Debug\\", pasta);

            localArquivoCompleto = string.Format("{0}\\{1}\\{2}\\{3}", localArquivoBase, feature, scenario, dateTime);

            if (!Directory.Exists(localArquivoCompleto))
            {
                Directory.CreateDirectory(localArquivoCompleto);
            }

            ScreenshotImageFormat extensaoArquivo = ScreenshotImageFormat.Jpeg;

            List <string> arquivos = new List <string>(Directory.GetFiles(localArquivoCompleto));
            var           nome     = localArquivoCompleto + "\\" + "Print" + tempo + ".Jpeg";

            if (arquivos.Contains(nome))
            {
                fileName = null;
            }
            else
            {
                fileName            = "Print" + tempo;
                nomeArquivoCompleto = string.Format("{0}\\{1}.{2}", localArquivoCompleto, fileName, extensaoArquivo.ToString());
            }
            arquivos.Clear();

            try
            {
                ((ITakesScreenshot)DriverFactory.INSTANCE)
                .GetScreenshot()
                .SaveAsFile(nomeArquivoCompleto, extensaoArquivo);
            }
            catch (Exception ex)
            {
                var mensagemErro = string.Format("{0}\r\n{1}\r\n\r\n{2}",
                                                 "Ocorreu um erro ao tirar o print da evidência.",
                                                 ex.Message,
                                                 ex.StackTrace);

                Console.WriteLine(mensagemErro);
            }


            return(localArquivoCompleto);
            //return nomeArquivoCompleto;
        }
Exemplo n.º 13
0
        private void SaveScreenshot(string filePath, ScreenshotImageFormat format = ScreenshotImageFormat.Png)
        {
            try
            {
                FileHelper.CreateDirectoryIfNotExist(filePath);

                WebDriver.GetScreenshot().SaveAsFile(filePath, format);
            }
            catch (Exception ex)
            {
                Log($"Failed to save screenshot {filePath}: {ex.Message}");
            }
        }
Exemplo n.º 14
0
        protected void TakeScreenshot(string filename, ScreenshotImageFormat format)
        {
            try
            {
                var screenshot = Path.Combine(TestContext.CurrentContext.TestDirectory, filename);

                ((RemoteWebDriver)_driver).GetScreenshot().SaveAsFile(screenshot, format);

                TestContext.AddTestAttachment(screenshot);
            }
            catch (Exception ex)
            {
                TestContext.WriteLine($"Error taking Screenshot '{filename}': {ex.Message}");
            }
        }
Exemplo n.º 15
0
        /// <summary>
        /// Saves a screenshot to a file. Overwrites the already existing file and creates non-existent directories.
        /// </summary>
        /// <param name="fileName">The file name to save the screenshot to. May include relative or absolute path.</param>
        /// <param name="format">A format to save the image to.</param>
        /// <returns>An instance of this class.</returns>
        public UIPage SaveScreenshot(string fileName, ScreenshotImageFormat format = ScreenshotImageFormat.Png)
        {
            if (!Path.HasExtension(fileName))
            {
                fileName = Path.ChangeExtension(fileName, format.ToString().ToLower());
            }
            if (!Path.IsPathRooted(fileName))
            {
                fileName = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), fileName);
            }
            Directory.CreateDirectory(Path.GetDirectoryName(fileName));

            Driver.GetScreenshot().SaveAsFile(fileName, format);

            return(this);
        }
Exemplo n.º 16
0
        /// <summary>
        ///     Takes a screenshot of the page and saves it in passed file path with passed file name and file format.
        /// </summary>
        /// <param name="driver"></param>
        /// <param name="fileName">The image file name.</param>
        /// <param name="filePath">The The full path and file name to save the screenshot to..</param>
        /// <param name="imageFormat">
        ///     A <see cref="T:OpenQA.Selenium.ScreenshotImageFormat" /> value indicating the format
        ///     to save the image to.
        /// </param>
        /// <returns>The <see cref="string" /> type value of image path.</returns>
        public static string TakeScreenshot(this IWebDriver driver, string fileName, string filePath,
                                            ScreenshotImageFormat imageFormat)
        {
            var screen = driver.TakeScreenshotAsScreenshot().AsByteArray;

            if (!Directory.Exists(filePath))
            {
                Directory.CreateDirectory(filePath);
            }
            var filePathAndName = Path.Combine(filePath,
                                               $"{fileName}-{DateTime.UtcNow.Ticks}.{imageFormat}");

            using var save = File.Create(filePathAndName);
            save.Write(screen);
            return(filePathAndName);
        }
Exemplo n.º 17
0
        public static void PrintScreen(string fileName, ScreenshotImageFormat imageFormat, string path = null)
        {
            if (String.IsNullOrEmpty(path))
            {
                path = ConfigurationManager.AppSettings["DefaultImagePath"];
            }
            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
            }

            var        file = path + fileName + "." + imageFormat.ToString();
            Screenshot ss   = ((ITakesScreenshot)driver).GetScreenshot();

            ss.SaveAsFile(file);
        }
Exemplo n.º 18
0
        /// <summary>
        /// Saves the screenshot to a file, overwriting the file if it already exists.
        /// </summary>
        /// <param name="fileName">The full path and file name to save the screenshot to.</param>
        /// <param name="format">A <see cref="ScreenshotImageFormat"/> value indicating the format
        /// to save the image to.</param>
        public void SaveAsFile(string fileName, ScreenshotImageFormat format)
        {
            using (MemoryStream imageStream = new MemoryStream(this.byteArray))
            {
#if NETCOREAPP2_0
                Image <Rgba32> image = Image.Load(imageStream);
                using (FileStream fileStream = new FileStream(fileName, FileMode.Create))
                {
                    image.Save(fileStream, ConvertScreenshotImageFormat(format));
                }
#else
                Image screenshotImage = Image.FromStream(imageStream);
                screenshotImage.Save(fileName, ConvertScreenshotImageFormat(format));
#endif
            }
        }
Exemplo n.º 19
0
        public void Execute_NoArgs_CallSaveAsFile(string filename, ScreenshotImageFormat imageFormat)
        {
            // Arrange
            var command    = new ScreenshotCommand(filename, DefaultDirectoryPath);
            var webDriver  = Substitute.For <IWebDriver, ITakesScreenshot>();
            var screenshot = Substitute.For <Screenshot>(Convert.ToBase64String(Encoding.UTF8.GetBytes("fake")));

            webDriver.TakeScreenshot().Returns(screenshot);

            // Act
            IgnoreExceptions.Run(() => command.Execute(webDriver));

            // Assert
            IgnoreExceptions.Run <ArgumentException>(() =>
            {
                screenshot.Received().SaveAsFile(filename, imageFormat);
            });
        }
Exemplo n.º 20
0
 public void SavePic(string path, ScreenshotImageFormat type = ScreenshotImageFormat.Jpeg, bool isFull = false)
 {
     if (isFull)
     {
         string str = path;
         ((ChromeDriver)_driver).ExecuteChromeCommand("Emulation.setDeviceMetricsOverride", new Dictionary <string, object>()
         {
             ["width"]             = ((RemoteWebDriver)_driver).ExecuteScript("return Math.max(window.innerWidth,document.body.scrollWidth,document.documentElement.scrollWidth)", Array.Empty <object>()),
             ["height"]            = ((RemoteWebDriver)_driver).ExecuteScript("return Math.max(window.innerHeight,document.body.scrollHeight,document.documentElement.scrollHeight)", Array.Empty <object>()),
             ["deviceScaleFactor"] = ((RemoteWebDriver)_driver).ExecuteScript("return window.devicePixelRatio", Array.Empty <object>()),
             ["mobile"]            = ((RemoteWebDriver)_driver).ExecuteScript("return typeof window.orientation !== 'undefined'", Array.Empty <object>())
         });
         ((RemoteWebDriver)_driver).GetScreenshot().SaveAsFile(str, ScreenshotImageFormat.Png);
     }
     else
     {
         WebDriverExtensions.TakeScreenshot(_driver).SaveAsFile(path, type);
     }
 }
Exemplo n.º 21
0
        public void WEBTestTakeScreenshot()
        {
            using (var xrmBrowser = new Api.Browser(TestSettings.Options))
            {
                xrmBrowser.LoginPage.Login(_xrmUri, _username, _password);
                xrmBrowser.GuidedHelp.CloseGuidedHelp();

                ScreenshotImageFormat fileFormat = ScreenshotImageFormat.Tiff;  // Image Format -> Png, Jpeg, Gif, Bmp and Tiff.
                string strFileName = String.Format("Screenshot_{0}.{1}", DateTime.Now.ToString("yyyy_MM_dd_HH_mm_ss"), fileFormat);
                xrmBrowser.TakeWindowScreenShot(strFileName, fileFormat);
                if (!File.Exists(strFileName))
                {
                    Assert.Fail(String.Format("Following file '{0}' was not found", strFileName));
                }
                else
                {
                    Console.WriteLine(Path.GetFullPath(strFileName));
                }
            }
        }
Exemplo n.º 22
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="screenshotFile">File path were screen shot will be saved.</param>
        /// <returns>Full path where screen shot file is saved.</returns>
        public static string PrintScreen(string screenshotFile = "SS.Png")
        {
            // Save a screen shot.
            string ssExt = Path.GetExtension(screenshotFile).ToUpper();
            ScreenshotImageFormat ssiFormat = ScreenshotImageFormat.Png;

            switch (ssExt)
            {
            case "JPG":
                ssiFormat = ScreenshotImageFormat.Jpeg;
                break;

            default:        // If not 'jpg', then make it 'png'.
                ssiFormat = ScreenshotImageFormat.Png;
                Path.ChangeExtension(screenshotFile, "png");
                break;
            }

            ((ITakesScreenshot)Driver).GetScreenshot().SaveAsFile(screenshotFile, ssiFormat);

            return(Path.GetFullPath(screenshotFile));
        }
Exemplo n.º 23
0
        /// <summary>
        /// ASCII
        /// </summary>
        /// <param name="value"></param>
        /// <returns></returns>
        public static void Save(ChromeDriver driver, string path, ScreenshotImageFormat type, bool isFull = false)
        {
            if (isFull)
            {
                var filePath = path;

                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)");
                //返回当前显示设备的物理像素分辨率与 CSS 像素分辨率的比率
                metrics["deviceScaleFactor"] = driver.ExecuteScript("return window.devicePixelRatio");
                metrics["mobile"]            = driver.ExecuteScript("return typeof window.orientation !== 'undefined'");
                driver.ExecuteChromeCommand("Emulation.setDeviceMetricsOverride", metrics);

                driver.GetScreenshot().SaveAsFile(filePath, ScreenshotImageFormat.Png);
            }
            else
            {
                Screenshot shot = driver.TakeScreenshot();
                shot.SaveAsFile(path, type);
            }
        }
Exemplo n.º 24
0
        /// <summary>
        /// Saves the screenshot to a file, overwriting the file if it already exists.
        /// </summary>
        /// <param name="fileName">The full path and file name to save the screenshot to.</param>
        /// <param name="format">A <see cref="ScreenshotImageFormat"/> value indicating the format
        /// to save the image to.</param>
        public void SaveAsFile(string fileName, ScreenshotImageFormat format)
        {
#if NETCOREAPP2_0 || NETSTANDARD2_0
            if (format != ScreenshotImageFormat.Png)
            {
                throw new WebDriverException(".NET Core does not support image manipulation, so only Portable Network Graphics (PNG) format is supported");
            }
#endif

            using (MemoryStream imageStream = new MemoryStream(this.byteArray))
            {
#if NETCOREAPP2_0 || NETSTANDARD2_0
                using (FileStream fileStream = new FileStream(fileName, FileMode.Create))
                {
                    imageStream.WriteTo(fileStream);
                }
#else
                Image screenshotImage = Image.FromStream(imageStream);
                screenshotImage.Save(fileName, ConvertScreenshotImageFormat(format));
#endif
            }
        }
Exemplo n.º 25
0
        private static IImageFormat ConvertScreenshotImageFormat(ScreenshotImageFormat format)
        {
            IImageFormat returnedFormat = ImageFormats.Png;

            switch (format)
            {
            case ScreenshotImageFormat.Jpeg:
                returnedFormat = ImageFormats.Jpeg;
                break;

            case ScreenshotImageFormat.Gif:
                returnedFormat = ImageFormats.Gif;
                break;

            case ScreenshotImageFormat.Bmp:
                returnedFormat = ImageFormats.Bitmap;
                break;

            case ScreenshotImageFormat.Tiff:
                throw new WebDriverException("TIFF image format not supported by .NET Core library");
            }

            return(returnedFormat);
        }
Exemplo n.º 26
0
        /// <summary>
        /// Tira um print da página atual e salva no arquivo especificado
        /// </summary>
        /// <param name="nomeArquivo">Nome do arquivo</param>
        /// <param name="filePath">Diretório onde a imagem será salva</param>
        /// <param name="format">Formato da imagem salva</param>
        public void TakeScreeshot(string nomeArquivo, string filePath, ScreenshotImageFormat format)
        {
            try
            {
                if (string.IsNullOrEmpty(filePath))
                {
                    throw new ArgumentException("É necessário informar um diretório onde o arquivo será salvo.");
                }

                if (!Directory.Exists(filePath))
                {
                    Directory.CreateDirectory(filePath);
                }

                ITakesScreenshot screenshot = Driver as ITakesScreenshot;
                Screenshot       shot       = screenshot.GetScreenshot();

                shot.SaveAsFile(ScreenShotHelper.FormatFileName(nomeArquivo, filePath, format), format);
            }
            catch (WebDriverException e)
            {
                throw new WebDriverException(e.Message.ToString());
            }
        }
        public static void TakeScreenShot(this IWebDriver iWebDriver, string fileName, ScreenshotImageFormat imageFormat)
        {
            var tempDriver = (ITakesScreenshot)iWebDriver;
            var screenShot = tempDriver.GetScreenshot();

            screenShot.SaveAsFile(fileName, imageFormat);
        }
Exemplo n.º 28
0
 /// <summary>
 /// Saves the screenshot to a Portable Network Graphics (PNG) file, overwriting the
 /// file if it already exists.
 /// </summary>
 /// <param name="fileName">The full path and file name to save the screenshot to.</param>
 /// <param name="format">A <see cref="ScreenshotImageFormat"/> value indicating the format to save the image to.</param>
 public new void SaveAsFile(string fileName, ScreenshotImageFormat format)
 {
     // mock method - should not do anything
 }
Exemplo n.º 29
0
 /// <summary>
 /// Saves the screenshot to a file, overwriting the file if it already exists.
 /// </summary>
 /// <param name="fileName">The full path and file name to save the screenshot to.</param>
 /// <param name="format">A <see cref="ScreenshotImageFormat"/> value indicating the format
 /// to save the image to.</param>
 public void SaveAsFile(string fileName, ScreenshotImageFormat format)
 {
     this.SaveAsFile(fileName, ConvertScreenshotImageFormat(format));
 }
Exemplo n.º 30
0
        /// <summary>
        /// Returns an <see cref="Image"/> representing a screen image of the test browser.
        /// </summary>
        /// <param name="format">The <see cref="ScreenshotImageFormat"/> format of the images.</param>
        public Image GetScreenshot(ScreenshotImageFormat format = ScreenshotImageFormat.Png)
        {
            var screenshot = GetScreenshot();

            return(Image.FromStream(new MemoryStream(screenshot.AsByteArray)));
        }