public static void WaitForPopulatedDatagrid(GridPattern grid, TimeSpan timeout) { var stableTimeToConsiderPopulated = TimeSpan.FromSeconds(1); int lastRowCount = 0; Stopwatch swStable = new Stopwatch(); var sw = Stopwatch.StartNew(); do { if (grid.Current.RowCount > 0) { if (swStable.IsRunning) { if (grid.Current.RowCount != lastRowCount) { swStable.Restart(); } else if (swStable.Elapsed >= stableTimeToConsiderPopulated) { return; } } else { swStable.Start(); } lastRowCount = grid.Current.RowCount; } Thread.Sleep(TimeSpan.FromMilliseconds(100)); //be cpu-friendly } while (sw.Elapsed < timeout); throw new TimeoutException("Timed out waiting for populated datagrid after " + timeout.TotalSeconds + "sec"); }
private IEnumerable<AutomationElement> GetColumnValuesForRow(GridPattern gridPattern, Int32 rowIndex) { for (int y = 0; y < gridPattern.Current.ColumnCount; y++) { var cellElement = gridPattern.GetItem(rowIndex, y); yield return TreeWalker.RawViewWalker.GetFirstChild(cellElement); } }
public Table(AutomationElement element) : base(element) { _pattern = (GridPattern)element.GetCurrentPattern(GridPattern.Pattern); }
/// <summary> /// 初始化(ip列表),并得到IP可用数 /// </summary> /// <returns></returns> public bool InitGridPattern() { bool result = false; try { AutomationElement proxyThorn = AutomationElement.RootElement.FindFirst(TreeScope.Children, new PropertyCondition(AutomationElement.NameProperty, "花刺代理验证(ProxyThorn)1.8")); var listCondition = new AndCondition( new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.DataGrid), new PropertyCondition(AutomationElement.NameProperty, "List2")); var listGrid = proxyThorn.FindFirst(TreeScope.Children, listCondition); var grid = (GridPattern)listGrid.GetCurrentPattern(GridPattern.Pattern); gridPattern = grid; gridRowCount = grid.Current.RowCount; result = true; } catch (Exception) { } return result; }
/// ------------------------------------------------------------------- /// <summary></summary> /// ------------------------------------------------------------------- internal GridPatternWrapper(AutomationElement element, string testSuite, TestPriorities priority, TypeOfControl typeOfControl, TypeOfPattern typeOfPattern, string dirResults, bool testEvents, IApplicationCommands commands) : base(element, testSuite, priority, typeOfControl, typeOfPattern, dirResults, testEvents, commands) { m_pattern = (GridPattern)GetPattern(m_le, m_useCurrent, GridPattern.Pattern); }
public DataGrid(AutomationElement ele, string automationID) { this._datagrid = Helper.ExtractElementByAutomationID(ele, automationID); Helper.ValidateArgumentNotNull(_datagrid, "DataGrid AutomationElement "); this._gridPattern = _datagrid.GetCurrentPattern(GridPattern.Pattern) as GridPattern; }
internal GridPatternInformation(GridPattern pattern, bool cache) { this.pattern = pattern; this.cache = cache; }
public TableWrapper(AutomationWrapper automationWrapper, GridPattern pattern) : base(automationWrapper, pattern) { }
protected override void CustomFixtureSetUp () { base.CustomFixtureSetUp (); gridPattern = (GridPattern) table1Element.GetCurrentPattern (GridPattern.Pattern); tablePattern = (TablePattern) table1Element.GetCurrentPattern (TablePattern.Pattern); }
private void GridPatternTestInternal (GridPattern pattern) { Assert.AreEqual (3, pattern.Current.ColumnCount, "ColumnCount"); //Besides the 2 data rows, there is an additional new data row. Assert.AreEqual (3, pattern.Current.RowCount, "RowCount"); var child = pattern.GetItem (0, 1); Assert.AreEqual ("Alice", child.Current.Name, "Item [1,1].Name"); child = pattern.GetItem (1, 0); Assert.AreEqual (ControlType.CheckBox, child.Current.ControlType, "Item [0,0].ControlType"); var toggle = (TogglePattern ) child.GetCurrentPattern (TogglePattern.Pattern); Assert.AreEqual (ToggleState.On, toggle.Current.ToggleState, "Item [0,0].ToggleState"); }
internal GridPatternInformation (GridPattern pattern, bool cache) { this.pattern = pattern; this.cache = cache; }