public void LargeViewTextboxesEnterTestData(ToolType tool, UITestControl theTab) { //Find the start point UITestControl theStartButton = WorkflowDesignerUIMap.FindControlByAutomationId(theTab, "Start"); Point workflowPoint1 = new Point(theStartButton.BoundingRectangle.X, theStartButton.BoundingRectangle.Y + 200); // Drag the tool onto the workflow ToolboxUIMap.DragControlToWorkflowDesigner(tool, workflowPoint1); WorkflowDesignerUIMap.OpenCloseLargeView(tool, theTab); // Add the data! List <UITestControl> listOfTextboxes = GetAllTextBoxesFromLargeView(tool.ToString(), theTab); int counter = 0; foreach (var textbox in listOfTextboxes) { WpfEdit tb = textbox as WpfEdit; if (tb != null && !tb.IsPassword) { tb.SetFocus(); SendKeys.SendWait("[[theVar" + counter.ToString(CultureInfo.InvariantCulture) + "]]"); } counter++; } }
/// <summary> /// Tells you if a WpfEdit is on read only mode. /// </summary> /// <param name="control">The target wpf edit automation element.</param> /// <returns>True if the wpfEdit is readOnly, False otherwise.</returns> /// <exception cref="ArgumentNullException">richText</exception> /// <exception cref="InvalidOperationException">Cannot retrieve the info from the control</exception> public static bool IsReadOnly(this WpfEdit richText) { if (richText == null) { throw new ArgumentNullException("richText"); } AutomationElement element = WpfControlExtensions.GetAutomationElement(richText); richText.SetFocus(); var pattern = element.GetCurrentPattern(TextPattern.Pattern) as TextPattern; if (pattern == null) { throw new InvalidOperationException("Cannot retrieve the info from the control"); } //pattern.DocumentRange.Select(); TextPatternRange[] selection = pattern.GetSelection(); if (selection.Any()) { object attValue = selection[0].GetAttributeValue(TextPattern.IsReadOnlyAttribute); if (attValue == null) { throw new InvalidOperationException("Cannot retrieve the info from the control"); } //pattern.DocumentRange.RemoveFromSelection(); return(bool.Parse(attValue.ToString())); } throw new InvalidOperationException("Cannot retrieve the info from the control"); }