Beispiel #1
0
        public void Execute(
            string inputPath,
            string savePath = "/",
            int timeout     = 30,
            int width       = 1920,
            int height      = 1080,
            int threads     = 4,
            bool ui         = false,
            int wait        = 0)
        {
            if (inputPath is null)
            {
                _screenshotTaker.TakeScreenshotsFromStream();
            }
            else
            {
                var storage = new ScreenshotRequestsStorage(_fileOpeningService.GetUrlsFromFile(inputPath));
                if (ui)
                {
                    _consoleWriter.Write(storage);
                    storage.StorageEvent += (sender, args) => { _consoleWriter.Write(storage); };
                }

                _screenshotTaker.TakeScreenshotsFromFile(storage, timeout, width, height, savePath, threads, wait);
                _resultSaver.SaveTimeoutAndErrors(storage, inputPath.Contains("\\") ? inputPath.Substring(0, inputPath.LastIndexOf("\\")) : "");
            }
        }
Beispiel #2
0
        public void SaveTimeoutAndErrors(ScreenshotRequestsStorage storage, string path)
        {
            var timeouts = storage.Where(r => r.Result == "Timeout").Select(r => r.Url);
            var errors   = storage.Where(r => r.Result == "Error").Select(r => r.Url);

            WriteFile(timeouts, path, "timeouts");
            WriteFile(errors, path, "errors");
        }
Beispiel #3
0
 public void Write(ScreenshotRequestsStorage storage)
 {
     lock (locker)
     {
         Console.Clear();
         ConsoleTable
         .From(storage)
         .Write();
         Console.SetCursorPosition(0, 0);
     }
 }
Beispiel #4
0
        private void TakeScreenshots(ScreenshotRequestsStorage storage, int timeout, int width, int height, string savePath, int threads, int wait)
        {
            Stopwatch stopwatch = new Stopwatch();

            stopwatch.Start();

            Parallel.ForEach(storage, new ParallelOptions()
            {
                MaxDegreeOfParallelism = threads
            }, (req) => TakeScreenshot(req, timeout, width, height, savePath, wait));

            stopwatch.Stop();
            Console.WriteLine($"Elapsed: {stopwatch.Elapsed}");
            _webDriverFactory.Dispose();
        }
Beispiel #5
0
 public void TakeScreenshotsFromFile(ScreenshotRequestsStorage storage, int timeout, int width, int height, string savePath, int threads, int wait)
 {
     TakeScreenshots(storage, timeout, width, height, savePath, threads, wait);
 }