public static List <string> GetExistedNamesForChildWebElements(WebElementInfoViewModel el, WebElementsTreeUserControl webElementsTreeUserControl, string originalName) { List <string> existedNames = el.Parent == null ? webElementsTreeUserControl.WebElements?.Select(c => c.Name).ToList() : el.Parent.Elements?.Select(e => e.Name).ToList(); if (originalName != null) { existedNames.Remove(originalName); } return(existedNames); }
public static Func <WebElementInfoViewModel, string> GetCreateUpdateWebElementValidator( WebElementsTreeUserControl webElementsTreeUserControl, string originalName) { Func <WebElementInfoViewModel, string> validator = el => { StringBuilder result = new StringBuilder(); if (!VerifyName(el, webElementsTreeUserControl, originalName, out var error)) { result.AppendLine(error); } if (string.IsNullOrWhiteSpace(el.Name)) { result.AppendLine("WebElement Name couldn't be empty"); } if (string.IsNullOrWhiteSpace(el.Description)) { result.AppendLine("WebElement Description couldn't be empty"); } var declineEmptyLocator = el.ElementType == WebElementTypes.Directory || el.ElementType == WebElementTypes.Page; if (el is WebElementWithReferenceViewModel wRefModel) { declineEmptyLocator = !wRefModel.HasLocator; if (wRefModel.ElementType == WebElementTypes.Frame) { declineEmptyLocator = (wRefModel.Locator as FrameWebLocatorInfoViewModel).FrameLocatorType != FrameLocatorType.Locator; } } if (!declineEmptyLocator && string.IsNullOrWhiteSpace(el.Locator.LocatorValue)) { result.AppendLine("WebElement Locator.LocatorValue couldn't be empty"); } return(result.ToString()); }; return(validator); }
public static bool VerifyName(WebElementInfoViewModel el, WebElementsTreeUserControl webElementsTreeUserControl, string originalName, out string error) { error = null; var existedNames = GetExistedNamesForChildWebElements( el, webElementsTreeUserControl, originalName); if (existedNames.Contains(el.Name)) { error = $"WebElement with name: {el.Name} already exists on the level"; return(false); } return(true); }
public EditWebElementCommand(WebElementsTreeUserControl webElementsTreeUserControl) : base(webElementsTreeUserControl) { }
public DeleteWebElementCommand(WebElementsTreeUserControl webElementsTreeUserControl) : base(webElementsTreeUserControl) { }
public CreateWebElementCommand(string elementType, WebElementsTreeUserControl webElementsTreeUserControl) : base(webElementsTreeUserControl) { _elementType = elementType; }
public CopyNameCommand(WebElementsTreeUserControl webElementsTreeUserControl) : base(webElementsTreeUserControl) { }
public WebElementCommand(WebElementsTreeUserControl webElementsTreeUserControl) { _webElementsTreeUserControl = webElementsTreeUserControl; }
public WebElementMenuItemsFactory(WebElementsTreeUserControl webElementsTreeUserControl) { _webElementsTreeUserControl = webElementsTreeUserControl; }
public GoToReferencedCommand(WebElementsTreeUserControl webElementsTreeUserControl) : base(webElementsTreeUserControl) { }