Beispiel #1
0
        /// <summary>
        /// Saves the screenshot.
        /// </summary>
        /// <param name="fileName">Name of the file.</param>
        public void SaveScreenshot(string fileName)
        {
            //browser.SaveAs(fileName);

            DirectoryHelper.CreateIfNotExists(Path.GetDirectoryName(fileName));

            var builder = new StringBuilder();

            builder.AppendLine(pageHeader);
            builder.AppendLine(browser.Html);
            builder.AppendLine("</HTML>");
            var html = builder.ToString();

            try
            {
                var serializer = new HtmlSerializer(browser.Uri, html, Encoding.UTF8);
                serializer.FileStorage = new FileSystemStorage(fileName);
                serializer.SaveContent();
            }
            catch (Exception ex)
            {
                AppCore.LogSystem.Log.Error("Ошибка сериализации скриншота", ex);
                SimpleSaveScreenshot(fileName, html);
            }
        }