コード例 #1
0
ファイル: ScreenshotPlugin.cs プロジェクト: tamirg7/BELLATRIX
        protected override void PreTestCleanup(object sender, PluginEventArgs e)
        {
            try
            {
                if (_isEnabled && e.TestOutcome == TestOutcome.Failed)
                {
                    var    screenshotSaveDir  = _screenshotOutputProvider.GetOutputFolder();
                    var    screenshotFileName = _screenshotOutputProvider.GetUniqueFileName(e.TestFullName);
                    string image     = _screenshotEngine.TakeScreenshot(e.Container);
                    string imagePath = Path.Combine(screenshotSaveDir, screenshotFileName);
                    File.WriteAllBytes(imagePath, Convert.FromBase64String(image));
                    _screenshotPluginProvider.ScreenshotGenerated(e, imagePath);
                }
            }
            catch
            {
                // Ignore since it is failing often because of bugs in Remote driver for Chrome
            }

            base.PreTestCleanup(sender, e);
        }
コード例 #2
0
        protected override void PreAfterScenario(object sender, TestWorkflowPluginEventArgs e)
        {
            GetTestScreenshotOnFailMode(e.TestOutcome);

            try
            {
                if (ScreenshotWorkflowPluginContext.ShouldTakeScreenshot)
                {
                    var    screenshotSaveDir  = _screenshotOutputProvider.GetOutputFolder();
                    var    screenshotFileName = _screenshotOutputProvider.GetUniqueFileName(e.TestFullName);
                    string image     = _screenshotEngine.TakeScreenshot(e.Container);
                    string imagePath = Path.Combine(screenshotSaveDir, screenshotFileName);
                    File.WriteAllBytes(imagePath, Convert.FromBase64String(image));
                    _screenshotPluginProvider.ScreenshotGenerated(e, imagePath);
                }
            }
            catch (Exception ex)
            {
                // Ignore
            }
        }
コード例 #3
0
        protected override void PreTestCleanup(object sender, TestWorkflowPluginEventArgs e)
        {
            GetTestScreenshotOnFailMode(e.TestMethodMemberInfo, e.TestOutcome);

            try
            {
                if (_shouldTakeScreenshot)
                {
                    var    screenshotSaveDir  = _screenshotOutputProvider.GetOutputFolder();
                    var    screenshotFileName = _screenshotOutputProvider.GetUniqueFileName(e.TestFullName);
                    string image     = _screenshotEngine.TakeScreenshot(e.Container);
                    string imagePath = Path.Combine(screenshotSaveDir, screenshotFileName);
                    File.WriteAllBytes(imagePath, Convert.FromBase64String(image));
                    _screenshotPluginProvider.ScreenshotGenerated(e, imagePath);
                }
            }
            catch (Exception ex)
            {
                // Ignore since it is failing often because of bugs in Remote driver for Chrome
            }

            base.PreTestCleanup(sender, e);
        }