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"); }
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(""); }