internal static string FormatComponentName(this TermMatch match, string[] values) { string format; switch (match) { case TermMatch.Contains: format = "Containing '{0}'"; break; case TermMatch.Equals: format = "{0}"; break; case TermMatch.StartsWith: format = "Starting with '{0}'"; break; case TermMatch.EndsWith: format = "Ending with '{0}'"; break; default: throw ExceptionFactory.CreateForUnsupportedEnumValue(match, nameof(match)); } string combinedValues = TermResolver.ToDisplayString(values); return(string.Format(format, combinedValues)); }
protected override By CreateScopeBy() { string scopeXPath = Metadata.ComponentDefinitionAttribute?.ScopeXPath ?? "body"; StringBuilder xPathBuilder = new StringBuilder($".//{scopeXPath}"); string titleElementXPath = Metadata.Get <WindowTitleElementDefinitionAttribute>()?.ScopeXPath; if (CanFindByWindowTitle && !string.IsNullOrWhiteSpace(titleElementXPath)) { xPathBuilder.Append( $"[.//{titleElementXPath}[{WindowTitleMatch.CreateXPathCondition(WindowTitleValues)}]]"); } return(By.XPath(xPathBuilder.ToString()).PopupWindow(TermResolver.ToDisplayString(WindowTitleValues))); }
public override string GetXPathCondition(object parameter, TermOptions termOptions) { IWebElement scope = component.ScopeSource.GetScopeElement(component, SearchOptions.SafelyAtOnce()); IWebElement label = scope.Get( By.XPath($".//label[{TermResolver.CreateXPathCondition(parameter, termOptions)}]"). SafelyAtOnce(). Label(TermResolver.ToDisplayString(parameter))); if (label != null) { string elementId = label.GetAttribute("for"); if (!string.IsNullOrEmpty(elementId)) { return($"[@id='{elementId}']"); } } return($"[ancestor::label[{TermResolver.CreateXPathCondition(parameter, termOptions)}]]"); }