Ejemplo n.º 1
0
        /// <summary>
        /// Configure the actor for Selenium reporting and returns an object that allows to retrieve the report. This is similar to using:
        /// - <see cref="Tranquire.ActorExtensions.WithReporting(Actor, IObserver{Reporting.ActionNotification}, ICanNotify)"/>
        /// - <see cref="TakeScreenshots(Actor, string, IObserver{ScreenshotInfo}, ITakeScreenshotStrategy)"/>
        /// </summary>
        /// <param name="actor">The actor</param>
        /// <param name="configuration">The reporting configuration</param>
        /// <param name="seleniumReporter">A <see cref="ISeleniumReporter"/> object that can be used to save the screenshots and retrieve the report at the end of the run</param>
        /// <returns></returns>
        public static Actor WithSeleniumReporting(
            this Actor actor,
            SeleniumReportingConfiguration configuration,
            out ISeleniumReporter seleniumReporter)
        {
            if (configuration == null)
            {
                throw new ArgumentNullException(nameof(configuration));
            }

            var xmlDocumentObserver = new XmlDocumentObserver();
            var textObservers       = new CompositeObserver <string>(configuration.TextOutputObservers.ToArray());
            var reportingObserver   = new CompositeObserver <ActionNotification>(
                xmlDocumentObserver,
                new RenderedReportingObserver(textObservers, RenderedReportingObserver.DefaultRenderer)
                );
            var saveScreenshotObserver = new SaveScreenshotsToFileOnComplete(configuration.ScreenshotDirectory);
            var screenshotObserver     = new CompositeObserver <ScreenshotInfo>(
                saveScreenshotObserver,
                new ScreenshotInfoToActionAttachmentObserverAdapter(xmlDocumentObserver),
                new RenderedScreenshotInfoObserver(textObservers)
                );

            seleniumReporter = new SeleniumReporter(xmlDocumentObserver, saveScreenshotObserver);
            return(configuration.ApplyWithReporting(actor, reportingObserver)
                   .TakeScreenshots(configuration.ScreenshotNameOrFormat,
                                    screenshotObserver,
                                    configuration.TakeScreenshotStrategy));
        }
Ejemplo n.º 2
0
 public void OnError_ShouldDoNothing(SaveScreenshotsToFileOnComplete sut)
 {
     sut.OnError(new Exception());
 }