protected override By CreateScopeBy() { string scopeXPath = Metadata.ComponentDefinitionAttribute?.ScopeXPath ?? "body"; StringBuilder xPathBuilder = new StringBuilder($".//{scopeXPath}"); string titleElementXPath = Metadata.Get <WindowTitleElementDefinitionAttribute>(x => x.At(AttributeLevels.Component))?.ScopeXPath; if (CanFindByWindowTitle && !string.IsNullOrWhiteSpace(titleElementXPath)) { xPathBuilder.Append( $"[.//{titleElementXPath}[{WindowTitleMatch.CreateXPathCondition(WindowTitleValues)}]]"); } return(By.XPath(xPathBuilder.ToString()).PopupWindow(TermResolver.ToDisplayString(WindowTitleValues))); }
/// <summary> /// Pass through / pre-setup to hook windows event. /// </summary> /// <param name="titleMatch">How to match window title.</param> /// <param name="windowTitle">Text (or regex) to match window title.</param> public void Setup(WindowTitleMatch titleMatch, string windowTitle) { if (string.IsNullOrEmpty(windowTitle)) { throw new ArgumentException($"{nameof(windowTitle)} must be set"); } if (titleMatch == WindowTitleMatch.Unknown) { throw new ArgumentException($"{nameof(titleMatch)} must be set"); } if (titleMatch == WindowTitleMatch.Regex) { _windowTitleRegex = new Regex(windowTitle); } _titleMatch = titleMatch; _windowTitle = windowTitle; // Now hook event. _hook = SetWindowsHook(); }