//temporary method for retrieving app. menu elements public void IdentifyMenuElements() { AutomationElement appMenu = appWindow.FindFirstByXPath($"*[@AutomationId='menu']"); FlaUI.Core.Conditions.TrueCondition condition = new TrueCondition(); FlaUI.Core.Definitions.TreeScope scope = FlaUI.Core.Definitions.TreeScope.Children; string menu = "Menu", menuItem = "", Item = ""; int idx = 0; AutomationElement[] cts = appMenu.FindAll(scope, condition); for (int x = 0; x < cts.LongCount(); x++) { if (cts[x].Properties.ControlType.ToString().Equals("MenuItem")) { menuItem = cts[x].Name; idx++; AutomationElement[] mnsi = cts[x].FindAllChildren(); for (int h = 0; h < mnsi.LongCount(); h++) { AutomationElement menuItemObject = mnsi[h]; mnsi[h].Click(); AutomationElement[] subComps = cts[x].FindAllChildren(); for (int d = 0; d < subComps.LongCount(); d++) { Item = subComps[d].Name; if (Item == null || Item.Equals("") || menuItem.Equals(Item)) { continue; } SaveElementAttributes("SceneComposer", menu, menuItem, menuItemObject, Item, idx++, subComps[d].FindFirstChild()); } } } } FileContent = objectDetails.ToString(); }
private static AutomationElement[] WaitUntilAtLeastNFound(AutomationElement parent, FlaUI.Core.Definitions.TreeScope treeScope, ConditionBase condition, int nr) { int delayMSeconds = 200; AutomationElement[] elements = { }; while (elements.Length < nr) { elements = parent.FindAll(treeScope, condition); if (elements.Length >= nr) { break; } Task.Delay(delayMSeconds).Wait(); } return(elements); }
private static AutomationElement WaitUntilFirstFound(AutomationElement parent, FlaUI.Core.Definitions.TreeScope treeScope, ConditionBase condition) { int delayMSeconds = 200; AutomationElement futureHandle = null; while (futureHandle is null) { futureHandle = parent.FindFirst(treeScope, condition); if (!(futureHandle is null)) { break; } Task.Delay(delayMSeconds).Wait(); } return(futureHandle); }