public WindowElement Find(string titleRegEx) { var handle = WindowsApiFunctions.GetWindowHandles().FirstOrDefault(i => Regex.IsMatch(i.Title, titleRegEx, RegexOptions.IgnoreCase)); if (handle == null) { throw new ElementException(string.Format("Unable to find window for title regex {0}", titleRegEx)); } return(new WindowElement(AutomationElement.FromHandle(handle.Handle))); }
public WindowElement Find(IntPtr windowHandle) { var handle = WindowsApiFunctions.GetWindowHandles().FirstOrDefault(i => i.Handle == windowHandle); if (handle == null) { throw new ElementException(string.Format("Unable to find window for handle: {0}", windowHandle)); } return(new WindowElement(AutomationElement.FromHandle(handle.Handle))); }
public IEnumerable <WindowElement> FindAllForProcess(int processId) { return(WindowsApiFunctions.GetWindowHandles().Where(i => i.ProcessId == processId).Select(i => new WindowElement(AutomationElement.FromHandle(i.Handle)))); }