/// <summary> /// Опасная функция ожидание отключения элемента /// </summary> /// <param name="nameAutomationId">Поиск элемента</param> public bool IsEnableElementTrue(string nameAutomationId, AutomationElement auto = null, bool isSubtree = false) { var isEnable = true; LegacyIAccessiblePattern valuePattern; uint status = 0; while (isEnable) { FindFirstElement(nameAutomationId, auto, isSubtree); try { if (FindElement.TryGetCurrentPattern(LegacyIAccessiblePatternIdentifiers.Pattern, out var patternObj)) { valuePattern = (LegacyIAccessiblePattern)patternObj; status = valuePattern.Current.State; if (status != 0) { return(false); } status = 0; } } catch { //ignore } } return(false); }
/// <summary> /// Паттерн прокрутки до элемента нажатия /// </summary> /// <param name="nameAutomationId"></param> public void ScrollPatternViewElement(string nameAutomationId) { var isProcess = true; while (isProcess) { if (IsEnableElements(nameAutomationId, null, false, 5) != null) { FindElement.SetFocus(); if (FindElement.TryGetCurrentPattern(ScrollItemPatternIdentifiers.Pattern, out var patternObj)) { var valuePattern = (ScrollItemPattern)patternObj; valuePattern.ScrollIntoView(); isProcess = false; } } } }