public string Invoke(LocatedElements locatedElements, string attributeName) => locatedElements .ConstraintCount(c => c == 1) .Elements .First() .GetAttribute(attributeName) .ToString();
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 locatedElements) => locatedElements .ConstraintCount(c => c == 1) .Elements .First() .Displayed .ToString();
public string Invoke(LocatedElements elements, string pattern) { elements .ConstraintCount(c => c > 0) .Elements .ForEach(e => VerifyElement(pattern, e)); return("true"); }
public void Invoke(LocatedElements elements, string value) => elements .ConstraintCount(c => c > 0) .Elements .ForEach( x => Context .Driver .ExecuteScriptWithArguments(JavascriptCode.SetValue(value), x));
public string Invoke(LocatedElements elements) => elements .ConstraintCount(c => c == 1) .Elements .First() .Size .Height .ToString();
public void Invoke(LocatedElements elements, OptionLocator optionLocator) { var action = new OpenQA.Selenium.Interactions.Actions(Context.Driver); elements .ConstraintCount(c => c == 1) .Elements .ForEach(x => PerformSelection(new SelectElement(x), optionLocator)); }
public string Invoke(LocatedElements elements) { if (!elements.Elements.Any()) { throw new AssertionException("Element expected to exists", "No element found", WebDrivers.Default); } return("true"); }
public void Invoke(LocatedElements elements) { var action = new OpenQA.Selenium.Interactions.Actions(Context.Driver); elements .ConstraintCount(c => c == 1) .Elements .ForEach(x => action .Release(x) .Perform()); }
public void Invoke(LocatedElements elements) { var action = new OpenQA.Selenium.Interactions.Actions(Context.Driver); elements .ConstraintCount(c => c > 0) .Elements .ForEach(x => action .MoveToElement(x) .DoubleClick() .Perform()); }
public void Invoke(LocatedElements elements, Point coordinate) { var action = new OpenQA.Selenium.Interactions.Actions(Context.Driver); elements .ConstraintCount(c => c == 1) .Elements .ForEach(x => action .MoveToElement(x, (int)coordinate.X, (int)coordinate.Y) .ClickAndHold() .Perform()); }
public void Invoke(LocatedElements elements, Point coordinates) { var action = new OpenQA.Selenium.Interactions.Actions(Context.Driver); elements .ConstraintCount(c => c > 0) .Elements .ForEach(e => action .MoveToElement(e, (int)coordinates.X, (int)coordinates.Y) .Click() .Perform()); }
public string GetIdentifier(IWebDriver driver, LocatedElements elements, IWebElement element) { var replacedCharacters = Path.GetInvalidFileNameChars() .Concat(new[] { '_' }) .ToArray(); var id = string.Join("_", GetElementIndex(elements, element), element.TagName, elements.Locator.Id, elements.Parameter); var safeId = string.Join("_", id.Split(replacedCharacters, StringSplitOptions.RemoveEmptyEntries)); return(safeId.Length > MAX_ID_LENGTH?safeId.Substring(0, MAX_ID_LENGTH) : safeId); }
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(""); }
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"); } }
public void Invoke(LocatedElements elements) => elements .ConstraintCount(c => c == 1) .Elements .First() .Submit();
public string Invoke(LocatedElements elements) => elements.Elements.Count() + "";
public string Invoke(LocatedElements elements) => elements .ConstraintCount(c => c == 1) .Elements .First() .TagName;
private int GetElementIndex(LocatedElements elements, IWebElement element) => elements .Elements .ToList() .IndexOf(element) + 1;
public void Invoke(LocatedElements elements) => elements .ConstraintCount(c => c > 0) .Elements .ForEach(x => Context.Driver.ExecuteScriptWithArguments(ChangeHighlightScript, x));
public string Invoke(LocatedElements locatedElements, string propertyName) => locatedElements .ConstraintCount(c => c == 1) .Elements .First() .GetCssValue(propertyName);
public void Invoke(LocatedElements elements, string keys) => elements .ConstraintCount(c => c > 0) .Elements .ForEach(e => TypeLikeHuman(e, keys));
public void Invoke(LocatedElements elements, string keys) => elements .ConstraintCount(c => c > 0) .Elements .ForEach(x => x.SendKeys(keys));
public string Invoke(LocatedElements elements) => elements .ConstraintCount(c => c == 1) .Elements .First() .GetAttribute("innerHTML");
public void Invoke(LocatedElements elements) => elements .ConstraintCount(c => c > 0) .Elements .ForEach(x => x.Click());
public void Invoke(LocatedElements elements) => elements .ConstraintCount(c => c == 1) .Elements .ForEach(x => x.SendKeys(""));