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 Type. SetProperty 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
- To set a property in a control, use SetProperty.
- To specify the property of the control to set, use the appropriate string from the PropertyNames class as the first parameter toSetProperty, with the property value as the second parameter.Example:SetProperty(myWinCheckBox.PropertyNames.Checked, true);
http://msdn.microsoft.com/en-us/library/dd465184(v=vs.100).aspx
WinButton uIButton1Button = this.UIMap.UIForm1Window.UIButton1Window.UIButton1Button;
String str = uIButton1Button.GetProperty("DisplayText").ToString();
MessageBox.Show(str);
Комментариев нет:
Отправить комментарий