Example #1
0
        public string Invoke(LocatedElements elements, string toleranceValue)
        {
            elements.ConstraintCount(c => c > 0);

            var configuration      = Context.ConfigurationProvider.Get(VisualRegressionConfiguration.Default);
            var baseVersionId      = configuration.ScreenshotStoreBaseVersionId;
            var referenceVersionId = configuration.ScreenshotStoreReferenceVersionId;
            var tolerance          = ParseToleranceLevel(toleranceValue.FallbackEmptyString(() => configuration.ScreenshotDiffTolerance));

            foreach (var element in elements.Elements)
            {
                var screenshot = element.TakeScreenshot(Context.Driver, Context.ConfigurationProvider);
                var elementId  = IdentityProvider.GetIdentifier(Context.Driver, elements, element);
                ScreenshotStore.Store(screenshot, Context.TopicId, elementId, referenceVersionId);

                var diff = ScreenshotStore.Compare(Context.TopicId, elementId, baseVersionId, referenceVersionId);
                Invoker.AddImage(ScreenshotStore.GetPath(Context.TopicId, elementId, configuration.ScreenshotStoreBaseVersionId));
                Invoker.AddImage(ScreenshotStore.GetPath(Context.TopicId, elementId, configuration.ScreenshotStoreReferenceVersionId));
                Invoker.AddImage(ScreenshotStore.GetPath(Context.TopicId, elementId, configuration.ScreenshotStoreDiffVersionId));

                Invoker.AddInfo($"Total difference {diff}");
                if (diff > tolerance)
                {
                    throw new ComparisonAssertionException(elementId, baseVersionId, referenceVersionId, diff * 100, tolerance * 100);
                }
            }

            return("true");
        }
Example #2
0
        public string Invoke(LocatedElements elements)
        {
            elements.ConstraintCount(c => c > 0);

            var configuration = Context.ConfigurationProvider.Get(VisualRegressionConfiguration.Default);
            var versionId     = configuration.ScreenshotStoreReferenceVersionId;

            foreach (var element in elements.Elements)
            {
                var screenshot = element.TakeScreenshot(Context.Driver, Context.ConfigurationProvider);
                var elementId  = IdentityProvider.GetIdentifier(Context.Driver, elements, element);
                ScreenshotStore.Store(screenshot, Context.TopicId, elementId, versionId);

                return(ScreenshotStore.GetPath(Context.TopicId, elementId, versionId));
            }
            return("");
        }
Example #3
0
        public string Invoke(LocatedElements elements)
        {
            elements.ConstraintCount(c => c == 1);

            var configuration  = Context.ConfigurationProvider.Get(VisualRegressionConfiguration.Default);
            var deltaVersionId = configuration.ScreenshotStoreDiffVersionId;
            var elementId      = IdentityProvider.GetIdentifier(Context.Driver, elements, elements.Elements.First());
            var image          = ScreenshotStore.GetPath(Context.TopicId, elementId, deltaVersionId);

            const long BYTE_LIMIT = 0x186A0;

            if (ImageInliner.TryInlineImage(image, "400", BYTE_LIMIT, out string base64))
            {
                return(base64);
            }
            else
            {
                return($"Image has reached a size limit of {BYTE_LIMIT} bytes");
            }
        }