所以我想实现编码的Ui测试,因为我们仍在我们公司手动测试。 不知何故,没有任何作用,更具体地说: 所以有一个带有4个文本框的wpf UserControl。但是在Test Builder中它只显示了4个Textbox中的2个。检查员也没有显示我所定义的任何属性。
答案 0 :(得分:0)
也许您应该尝试检查“ UiItemCustom”并检查是否有4个子项。
var _UiItemCustom = new WpfCustom(UiMainWindowWindow); //the father of this element is your Main Window element
_UiItemCustom.SearchProperties.Add(WpfCustom.PropertyNames.ControlType, "Custom");
_UiItemCustom.SearchProperties.Add(WpfCustom.PropertyNames.Name, "**THE CUSTOM NAME HERE**");
if(UiItemCustom.GetChildren().Count == 4){
//if the custom has 4 children the it has 4 textboxes (Maybe)
}
//if you want to hold the 4 textboxes in your hand then do the following.
var _textBox1 = new WpfEdit(_UiItemCustom.GetChildren()[0]); //TextBox1
var _textBox1 = new WpfEdit(_UiItemCustom.GetChildren()[1]); //TextBox2
var _textBox1 = new WpfEdit(_UiItemCustom.GetChildren()[2]); //TextBox3
var _textBox1 = new WpfEdit(_UiItemCustom.GetChildren()[3]); //TextBox4
如果要使用值填充文本框之一,请执行以下操作:
_textBox1.Text = "Hello World;
答案 1 :(得分:0)
示例为C#,但您可以轻松地将其转换为vb.net:http://converter.telerik.com/
您可以以递归的方式遍历ui元素以获取所有子项:
/// <summary>
/// Returns a complete tree of controls and child controls in a recursive way.
/// </summary>
/// <param name="parentControl"></param>
/// <returns></returns>
public ParentControl GetChildControls(UITestControl parentControl)
{
ParentControl parent = new ParentControl();
if (parentControl != null)
{
List<ParentControl> children = new List<ParentControl>();
foreach (UITestControl childControl in parentControl.GetChildren())
{
children.Add(GetChildControls(childControl));
}
parent.Children = new KeyValuePair<UITestControl, List<ParentControl>>(parentControl, children);
}
return parent;
}
父类:
public class ParentControl
{
internal KeyValuePair<UITestControl, List<ParentControl>> Children { get; set; }
internal string Value
{
get
{
return Children.Key.Name;
}
}
}