Example #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));
        }
Example #2
0
        /// <summary>
        /// Save the screenshots in the bmp format
        /// </summary>
        /// <param name="configuration">The configuration</param>
        /// <returns></returns>
        public static SeleniumReportingConfiguration WithScreenshotBmp(this SeleniumReportingConfiguration configuration)
        {
            if (configuration == null)
            {
                throw new ArgumentNullException(nameof(configuration));
            }

            return(configuration.WithScreenshotFormat(ScreenshotFormat.Bmp));
        }
Example #3
0
        public static Actor WithSeleniumReporting(
            this Actor actor,
            string screenshotDirectory,
            string screenshotNameOrFormat,
            out ISeleniumReporter seleniumReporter,
            params IObserver <string>[] textOutputObservers)
        {
            var configuration = new SeleniumReportingConfiguration(screenshotDirectory, screenshotNameOrFormat)
                                .AddTextObservers(textOutputObservers);

            return(actor.WithSeleniumReporting(configuration, out seleniumReporter));
        }