понедельник, 9 июня 2014 г.

Accessing Properties of UI Test Control

To get and set UI control specific property values, you can directly get or set the values the properties of a control, or you can use theUITestControl.GetProperty and UITestControl.SetProperty methods with the name of the specific property that you want you get or set.
GetProperty returns an object which can be cast to the appropriate TypeSetProperty accepts an object for the value of the property.

To get or set properties from UI test controls directly

  • With controls that derive from T:Microsoft.VisualStudio.TestTools.UITesting.UITestControl, such as T:Microsoft.VisualStudio.TestTools.UITesting.HtmlControls.HtmlList or T:Microsoft.VisualStudio.TestTools.UITesting.WinControls.WinComboBox, you can get or set their property values directly as follows:
    int i = myHtmlList.ItemCount;
    myWinCheckBox.Checked = true;
    

To get properties from UI test controls

  • To get a property value from a control, use GetProperty.
  • To specify the property of the control to get, use the appropriate string from the PropertyNames class in each control as the parameter to GetProperty.
  • GetProperty returns the appropriate data type, but this return value is cast as an Object. The return Object must then be cast to the appropriate type.
    Example:
    int i = (int)GetProperty(myHtmlList.PropertyNames.ItemCount);

To set properties for UI test controls

WinButton uIButton1Button = this.UIMap.UIForm1Window.UIButton1Window.UIButton1Button;

String str =  uIButton1Button.GetProperty("DisplayText").ToString();

MessageBox.Show(str);

Комментариев нет:

Отправить комментарий