예제 #1
0
        private void LoggingDriver_ExceptionThrown(object sender, WebDriverExceptionEventArgs e)
        {
            //TODO Consider to move somewere
            var path = _settings.ScreenshotsFolder;

            Directory.CreateDirectory(path);
            _loggingDriver.GetScreenshot().SaveAsFile(path + @"\failScreenshot.png", ImageFormat.Png);
        }
예제 #2
0
        public SeleniumFixture()
        {
            _usesDbFixture  = new UsesDbFixture();
            _webServer      = new WebServer().Start();
            _seleniumServer = new SeleniumServer().Start();

            var driver = new EventFiringWebDriver(new ChromeDriver(AppDomain.CurrentDomain.BaseDirectory));

            _browser = new Browser(driver);
            driver.ExceptionThrown += (object sender, WebDriverExceptionEventArgs e) =>
            {
                var timestamp = DateTime.Now.ToString("yyyy-MM-dd-hhmm-ss");
                driver.GetScreenshot().SaveAsFile("SeleniumException-" + timestamp + ".png", ImageFormat.Png);
            };
        }
        public void Dispose()
        {
            if (TestStatusResult == true)
            {
                File.WriteAllText(Report, File.ReadAllText(Report).Replace("@OUTCOME", "green"));
            }
            else
            {
                File.WriteAllText(Report, File.ReadAllText(Report).Replace("@OUTCOME", "red"));
            }

            try { using (StreamWriter sw = new StreamWriter(Report, true)) { sw.WriteLine($"<center><hr/><h4>Última Tela Apresentada</h4><img style='width:50%;height:50%;' src='data:image/png; base64, {WebDriver.GetScreenshot().AsBase64EncodedString}'/></center><hr/>"); } } catch { }

            try { driver.Quit(); } catch { }

            try { WebDriver.Quit(); } catch { }


            _output.WriteLine($"Result Teste: {Report}");
        }
예제 #4
0
 private void OnDriverOnExceptionThrown(object sender, WebDriverExceptionEventArgs e)
 {
     Console.WriteLine(e.ThrownException);
     _driver.GetScreenshot().SaveAsFile(_screenFilePath + "  screenOnException.png", ImageFormat.Png);
 }