public static UIObject GetTopLevelUIObject(UIObject topWindow) { if (topWindow == null) { throw new ArgumentNullException(paramName: nameof(topWindow)); } Log.Out(msg: "GetTopLevelUIObject: object"); UIObject element = null; if ((ControlType)topWindow.GetProperty(property: UIProperty.Get(name: "ControlType")) != ControlType.Window) { throw new InvalidOperationException(message: "topWindow didn't find a window (ControlType==Window) after app activation completed."); } if (topWindow.ClassName.Equals(value: "Windows.UI.Core.CoreWindow", comparisonType: StringComparison.OrdinalIgnoreCase)) { element = topWindow; } else { uint num; for (num = 0U; num < 10U && !topWindow.Children.TryFind(condition: UICondition.CreateFromClassName(className: "Windows.UI.Core.CoreWindow").AndWith(newCondition: UICondition.CreateFromName(name: topWindow.Name)), element: out element); ++num) { Thread.Sleep(millisecondsTimeout: 100); } if (element == null) { throw new UIObjectNotFoundException(message: string.Format(format: "Unable to find {0} in {1}", arg0: "Windows.UI.Core.CoreWindow", arg1: topWindow)); } Log.Out(msg: "Found {0} in {1} tries", (object)"Windows.UI.Core.CoreWindow", (object)num); } return(element); }
public UICollection <I> FindMultiple(UICondition condition) { var uiCollection = Duplicate(); uiCollection.AddFilter(condition: condition); return(uiCollection); }
public I Find(UICondition condition) { I element; if (!TryFind(condition: condition, element: out element)) { throw new UIObjectNotFoundException(searchDomain: ToString(), condition: condition); } return(element); }
public static UIObject Launch(string appName, UICondition topLevelWindowCondition) { Log.Out(msg: nameof(Launch)); UIObject source; using (var appLaunchWaiter = new AppLaunchWaiter(topLevelWindowCondition: topLevelWindowCondition)) { new ApplicationActivationManager().ActivateApplication(appUserModelId: appName, arguments: null, options: ActivateOptions.None, processId: out var _); appLaunchWaiter.Wait(); source = appLaunchWaiter.Source; } return(GetTopLevelUIObject(topWindow: source)); }
public static UIObject LaunchEx(string appName, UICondition topLevelWindowCondition) { Log.Out(msg: "Launch"); UIObject source; using (var appLaunchWaiter = new AppLaunchWaiter(topLevelWindowCondition: topLevelWindowCondition)) { AppStateManagementUtils.LaunchApplication(AumId: appName); appLaunchWaiter.Wait(); source = appLaunchWaiter.Source; } return(GetTopLevelUIObject(topWindow: source)); }
public static UIObject GetTopLevelUIObject(UICondition topLevelWindowCondition) { if (topLevelWindowCondition == null) { throw new ArgumentNullException(paramName: nameof(topLevelWindowCondition)); } Log.Out(msg: "GetTopLevelUIObject: condition"); UIObject element; if (!UIObject.Root.Descendants.TryFind(condition: topLevelWindowCondition, element: out element)) { throw new InvalidOperationException(message: "topLevelWindowCondition didn't find an element after app activation completed."); } return(GetTopLevelUIObject(topWindow: element)); }
public override Condition GlobalizeCondition( AutomationElement element, ref Dictionary <AutomationProperty, TranslatedStrings> propertyValueTranslations) { Condition condition = this._condition; if (UICondition.IsGlobalizableProperty(property: this._property)) { TranslatedStrings translatedStrings; if (!propertyValueTranslations.TryGetValue(key: this._property, value: out translatedStrings)) { translatedStrings = new TranslatedStrings(); propertyValueTranslations[key : this._property] = translatedStrings; } var localizedStrings = !(this._value is ILocalizationProvider2) ? new LocalizedStringsAdapter(taggedText: this._value.ToString()) : (ILocalizedStrings) new LocalizedStrings2(contextElement: element, provider: (ILocalizationProvider2)this._value); var translations = localizedStrings.GetTranslations(); if (1 == translations.Length) { translatedStrings.Add(translatedString: translations[0].Raw(), localizedStrings: localizedStrings, index: 0L); condition = new PropertyCondition(property: this._property, value: translations[0].DefaultString()); } else { var conditionArray = new Condition[translations.Length]; for (var index = 0; index < translations.Length; ++index) { translatedStrings.Add(translatedString: translations[index].Raw(), localizedStrings: localizedStrings, index: index); conditionArray[index] = new PropertyCondition(property: this._property, value: translations[index].DefaultString()); } condition = new OrCondition(conditions: conditionArray); } } return(condition); }
public static UIObject LaunchForProtocol( string appName, string uri, UICondition topLevelWindowCondition) { Log.Out(msg: nameof(LaunchForProtocol)); var riid1 = new Guid(g: "43826d1e-e718-42ee-bc55-a1e261c37bfe"); IShellItem shellItem; SHCreateItemFromParsingName(path: uri, pbc: IntPtr.Zero, riid: ref riid1, shellItem: out shellItem); var riid2 = new Guid(g: "b63ea76d-1f85-456f-a19c-48159efa858b"); IShellItemArray ppenum; STORAGE_SHCreateShellItemArrayFromShellItem(psi: shellItem, riid: ref riid2, ppenum: out ppenum); UIObject source; using (var appLaunchWaiter = new AppLaunchWaiter(topLevelWindowCondition: topLevelWindowCondition)) { new ApplicationActivationManager().ActivateForProtocol(appUserModelId: appName, itemArray: ppenum, processId: out var _); appLaunchWaiter.Wait(); source = appLaunchWaiter.Source; } return(GetTopLevelUIObject(topWindow: source)); }
public void AddFilter(UIProperty uiProperty, object value) { Navigator.AddFilter(condition: UICondition.Create(property: uiProperty, value: value)); }
public void AddFilter(UICondition condition) { Navigator.AddFilter(condition: condition); }
public static UICondition CreateTopLevelWindowCondition() { var deviceFamily = AnalyticsInfo.VersionInfo.DeviceFamily; return(deviceFamily.Equals(value: "Windows.Desktop", comparisonType: StringComparison.OrdinalIgnoreCase) || deviceFamily.Equals(value: "Windows.Server", comparisonType: StringComparison.OrdinalIgnoreCase) || deviceFamily.Equals(value: "Windows.Team", comparisonType: StringComparison.OrdinalIgnoreCase) ? UICondition.CreateFromClassName(className: "ApplicationFrameWindow") : UICondition.CreateFromClassName(className: "Windows.UI.Core.CoreWindow")); }
public bool Contains(string automationId) { return(Contains(condition: UICondition.CreateFromId(automationId: automationId))); }
public UICondition AndWith(UICondition newCondition) { Validate.ArgumentNotNull(parameter: newCondition, parameterName: nameof(newCondition)); Validate.ArgumentNotNull(parameter: newCondition.GlobalizableCondition, parameterName: "newCondition.GlobalizableCondition"); return(new UICondition(condition: new GlobalizableAndCondition(GlobalizableCondition, newCondition.GlobalizableCondition))); }
internal static bool Matches(AutomationElement element, UICondition condition) { Validate.ArgumentNotNull(parameter: condition, parameterName: nameof(condition)); return(condition.Matches(element: element)); }
public bool TryFind(string automationId, out I element) { return(TryFind(condition: UICondition.CreateFromId(automationId: automationId), element: out element)); }
public bool Contains(UIProperty uiProperty, object value) { return(Contains(condition: UICondition.Create(property: uiProperty, value: value))); }
public Context(UICondition treeCondition) { Validate.ArgumentNotNull(parameter: treeCondition, parameterName: nameof(treeCondition)); IsActivated = false; TreeCondition = treeCondition; }
public I Find(UIProperty uiProperty, object value) { return(Find(condition: UICondition.Create(property: uiProperty, value: value))); }
public I Find(string automationId) { return(Find(condition: UICondition.CreateFromId(automationId: automationId))); }
public bool TryFind(UICondition condition, out I element) { element = SafeFind(condition: condition); return(!(null == element)); }
public bool TryFind(UIProperty uiProperty, object value, out I element) { return(TryFind(condition: UICondition.Create(property: uiProperty, value: value), element: out element)); }
public static bool Matches(UIObject uiObject, UICondition condition) { Validate.ArgumentNotNull(parameter: uiObject, parameterName: nameof(uiObject)); Validate.ArgumentNotNull(parameter: condition, parameterName: nameof(condition)); return(condition.Matches(element: uiObject.AutomationElement)); }
public UICollection <I> FindMultiple(UIProperty uiProperty, object value) { return(FindMultiple(condition: UICondition.Create(property: uiProperty, value: value))); }
public bool Contains(UICondition condition) { return(!(null == SafeFind(condition: condition))); }
public UIObjectNotFoundException(string searchDomain, UICondition condition) { Validate.ArgumentNotNull(parameter: condition, parameterName: nameof(condition)); Initialize(searchDomain: searchDomain, searchCriteria: condition.ToString()); }
public void AddFilter(UICondition condition) { Filter.Add(condition: condition); }