private CUITControls.SilverlightCell GetCell(int iRow, int iCol) { SourceControl.WaitForControlReady(); CUITControls.SilverlightCell _SlCell = null; int rowCount = -1; foreach (CUITControls.SilverlightRow cont in SourceControl.Rows) { rowCount++; if (rowCount == iRow) { int colCount = -1; foreach (CUITControls.SilverlightCell cell in cont.Cells) { colCount++; if (colCount == iCol) { _SlCell = cell; break; } } } if (_SlCell != null) { break; } } return(_SlCell); }
/// <summary> /// Clicks on the center of the UITestControl based on its point on the screen. /// This may "work-around" Coded UI tests (on third-party controls) that throw the following exception: /// Microsoft.VisualStudio.TestTools.UITest.Extension.FailedToPerformActionOnBlockedControlException: Another control is blocking the control. Please make the blocked control visible and retry the action. /// </summary> public void PointAndClick() { SourceControl.WaitForControlReady(); int x = SourceControl.BoundingRectangle.X + SourceControl.BoundingRectangle.Width / 2; int y = SourceControl.BoundingRectangle.Y + SourceControl.BoundingRectangle.Height / 2; Mouse.Click(new Point(x, y)); }
public void Check() { SourceControl.WaitForControlReady(); if (!SourceControl.Checked) { SourceControl.Checked = true; } }
public void UnCheck() { SourceControl.WaitForControlReady(); if (SourceControl.Checked) { SourceControl.Checked = false; } }
/// <summary> /// Waits for the control to be ready and then sends keystrokes to generate the specified /// text string. /// </summary> /// <param name="text">The text for which to generate keystrokes.</param> /// <param name="modifierKeys"> /// The sum of one or more values of the <see cref="ModifierKeys"/> enumeration. /// </param> /// <param name="isEncoded">true if the text is encoded; otherwise, false.</param> /// <param name="isUnicode">true if the text is Unicode text; otherwise, false.</param> /// <remarks> /// The string may contain key modifiers. /// /// Control ^ /// Shift + /// Alt % /// Windows # /// /// To send a Control+A keyboard sequence, use <code>SendKeys("^a")</code>. /// /// To send a character that represents a key modifier, enclose the character in a pair of /// braces. For example, to send a plus sign, use <code>SendKeys("{+}")</code>. /// /// To send a brace, enclose the brace in a pair of braces. For example, to send an opening /// or closing brace, use <code>SendKeys("{{}")</code> or <code>SendKeys("{}}")</code>, /// respectively. /// </remarks> public void SendKeys( string text, ModifierKeys modifierKeys = ModifierKeys.None, bool isEncoded = false, bool isUnicode = true) { SourceControl.WaitForControlReady(); Keyboard.SendKeys(SourceControl, text, modifierKeys, isEncoded, isUnicode); }
/// <summary> /// Returns a list of all first level children of the current CUITe control. /// </summary> /// <returns>list of all first level children</returns> public override List <IControlBase> GetChildren() { SourceControl.WaitForControlReady(); var uicol = new List <IControlBase>(); foreach (UITestControl uitestcontrol in SourceControl.GetChildren()) { uicol.Add(WrapUtil((CUITControls.SilverlightControl)uitestcontrol)); } return(uicol); }
public int FindRow(int iCol, string sValueToSearch, HtmlTableSearchOptions option) { SourceControl.WaitForControlReady(); int iRow = -1; int rowCount = -1; foreach (CUITControls.HtmlControl control in SourceControl.Rows) { //control could be of ControlType.RowHeader or ControlType.Row rowCount++; int colCount = -1; foreach (CUITControls.HtmlControl cell in control.GetChildren()) //Cells could be a collection of HtmlCell and HtmlHeaderCell controls { colCount++; bool bSearchOptionResult = false; if (colCount == iCol) { if (option == HtmlTableSearchOptions.Normal) { bSearchOptionResult = (sValueToSearch == cell.InnerText); } else if (option == HtmlTableSearchOptions.NormalTight) { bSearchOptionResult = (sValueToSearch == cell.InnerText.Trim()); } else if (option == HtmlTableSearchOptions.StartsWith) { bSearchOptionResult = cell.InnerText.StartsWith(sValueToSearch); } else if (option == HtmlTableSearchOptions.EndsWith) { bSearchOptionResult = cell.InnerText.EndsWith(sValueToSearch); } else if (option == HtmlTableSearchOptions.Greedy) { bSearchOptionResult = (cell.InnerText.IndexOf(sValueToSearch) > -1); } if (bSearchOptionResult) { iRow = rowCount; break; } } } if (iRow > -1) { break; } } return(iRow); }
public void Select2() { SourceControl.WaitForControlReady(); string sOnClick = (string)SourceControl.GetProperty("onclick"); string sId = SourceControl.Id; if (sId == null || sId == "") { throw new GenericException("Select2(): No ID found for the RadioButton!"); } RunScript("document.getElementById('" + sId + "').checked=true;" + sOnClick); }
public int FindRow(int iCol, string sValueToSearch, SilverlightTableSearchOptions option) { SourceControl.WaitForControlReady(); int iRow = -1; int rowCount = -1; foreach (CUITControls.SilverlightRow cont in SourceControl.Rows) { rowCount++; int colCount = -1; foreach (CUITControls.SilverlightCell cell in cont.Cells) { colCount++; bool bSearchOptionResult = false; if (colCount == iCol) { if (option == SilverlightTableSearchOptions.Normal) { bSearchOptionResult = (sValueToSearch == cell.Value); } else if (option == SilverlightTableSearchOptions.NormalTight) { bSearchOptionResult = (sValueToSearch == cell.Value.Trim()); } else if (option == SilverlightTableSearchOptions.StartsWith) { bSearchOptionResult = cell.Value.StartsWith(sValueToSearch); } else if (option == SilverlightTableSearchOptions.EndsWith) { bSearchOptionResult = cell.Value.EndsWith(sValueToSearch); } else if (option == SilverlightTableSearchOptions.Greedy) { bSearchOptionResult = (cell.Value.IndexOf(sValueToSearch) > -1); } if (bSearchOptionResult) { iRow = rowCount; break; } } } if (iRow > -1) { break; } } return(iRow); }
private T GetCell <T>(int iRow, int iCol) where T : IHtmlControl { SourceControl.WaitForControlReady(); UITestControl htmlCell = null; int rowCount = -1; foreach (UITestControl row in SourceControl.Rows) { //control could be of ControlType.RowHeader or ControlType.Row rowCount++; if (rowCount != iRow) { continue; } int colCount = -1; foreach (UITestControl cell in row.GetChildren()) //Cells could be a collection of HtmlCell and HtmlHeaderCell controls { colCount++; if (colCount != iCol) { continue; } htmlCell = cell; break; } if (htmlCell != null) { break; } } Type t = typeof(T); ConstructorInfo ctor = GetConstructor(t, typeof(UITestControl)); return((T)ctor.Invoke( new object[] { htmlCell })); // call constructor }
/// <summary> /// Selects the item in the combobox by index. /// </summary> /// <param name="index">index of item</param> public void SelectItem(int index) { SourceControl.WaitForControlReady(); SourceControl.SelectedIndex = index; }
public void SetText(string sText) { SourceControl.WaitForControlReady(); _TextBox.Text = sText; }
/// <summary> /// Selects the item in the combobox. /// </summary> /// <param name="sItem">Item as string</param> public void SelectItem(string sItem) { SourceControl.WaitForControlReady(); SourceControl.SelectedItem = sItem; }
/// <summary> /// Wraps the WaitForControlReady method for a UITestControl. /// </summary> public void WaitForControlReady() { SourceControl.WaitForControlReady(); }
/// <summary> /// Wraps WaitForControlReady and DoubleClick methods for a UITestControl. /// </summary> public void DoubleClick() { SourceControl.WaitForControlReady(); Mouse.DoubleClick(SourceControl); }
/// <summary> /// Waits for the control to be ready and then double-clicks the specified mouse button. /// </summary> /// <param name="button"> /// The <see cref="MouseButtons"/> that will be used for double-clicking. /// </param> public void DoubleClick(MouseButtons button = MouseButtons.Left) { SourceControl.WaitForControlReady(); Mouse.DoubleClick(SourceControl, button); }
public void Select() { SourceControl.WaitForControlReady(); SourceControl.Selected = true; }
/// <summary> /// Waits for the control to be ready and then double-clicks the default mouse button while /// holding the specified modifier keys. /// </summary> /// <param name="modifierKeys"> /// <see cref="ModifierKeys"/> that will be used for double-clicking. /// </param> public void DoubleClick(ModifierKeys modifierKeys) { SourceControl.WaitForControlReady(); Mouse.DoubleClick(SourceControl, modifierKeys); }
/// <summary> /// Waits for the control to be ready and then presses the specified modifier keys without /// releasing them. /// </summary> /// <param name="keys"> /// The sum of one or more values of the <see cref="ModifierKeys"/> enumeration. /// </param> /// <remarks> /// Modifier keys that have been pressed must be explicitly released by using the /// <see cref="ReleaseModifierKeys"/>. /// </remarks> public void PressModifierKeys(ModifierKeys keys) { SourceControl.WaitForControlReady(); Keyboard.PressModifierKeys(SourceControl, keys); }
/// <summary> /// Waits for the control to be ready and then releases the specified keys that were /// previously pressed by using the <see cref="PressModifierKeys"/> method. /// </summary> /// <param name="keys"> /// The sum of one or more values of the <see cref="ModifierKeys"/> enumeration. /// </param> public void ReleaseModifierKeys(ModifierKeys keys) { SourceControl.WaitForControlReady(); Keyboard.ReleaseModifierKeys(SourceControl, keys); }
public void SetText(string sText) { SourceControl.WaitForControlReady(); SourceControl.CopyPastedText = sText; }
/// <summary> /// Waits for the control to be ready and then holds the specified modifier keys until /// the returned instance is disposed. /// </summary> /// <param name="keys"> /// The sum of one or more values of the <see cref="ModifierKeys"/> enumeration. /// </param> /// <returns> /// An instance that releases the modifier keys when disposed. /// </returns> /// <remarks> /// This method is an alternative to using <see cref="PressModifierKeys"/> and /// <see cref="ReleaseModifierKeys"/>. /// </remarks> public IDisposable HoldModifierKeys(ModifierKeys keys) { SourceControl.WaitForControlReady(); return(new ModifierKeysLifetime <T>(this, keys)); }
public string GetText() { SourceControl.WaitForControlReady(); return(SourceControl.Text); }
/// <summary> /// Wraps WaitForControlReady and SetFocus methods for a UITestControl. /// </summary> public void SetFocus() { SourceControl.WaitForControlReady(); SourceControl.SetFocus(); }