根据UISpy和inspector.exe,我有以下项目是一个按钮 我一直在想让这个按钮被按下而伤透了头,希望有人可以帮助我。
我要与之交互的按钮是名为“验证”的按钮
(对不起,图像客户端中的绿色不想显示所有项目)
我尝试在窗口中获取所有项目,但似乎无法从中找到项目
TestStack.White.UIItems.IUIItem[] items = window.GetMultiple(SearchCriteria.All);
我也尝试通过此按钮
SearchCriteria searchCriteria = SearchCriteria.ByText("Verify");
var button = window.Get<TestStack.White.UIItems.Button>(searchCriteria);
但这将返回零项
最后我尝试构建如下的“自定义工具栏”项
//Specify the ControlType which corresponds to the top level of Custom UI Item.
//White needs this when finding this item inside the window.
[ControlTypeMapping(CustomUIItemType.ToolBar)]
public class RibbonUIItem : CustomUIItem
{
// Implement these two constructors. The order of parameters should be same.
public RibbonUIItem(AutomationElement automationElement, ActionListener actionListener)
: base(automationElement, actionListener)
{
}
//Empty constructor is mandatory with protected or public access modifier.
protected RibbonUIItem() { }
//Verify Button
public virtual void Verify()
{
//Base class, i.e. CustomUIItem has property called Container. Use this find the items within this.
//Can also use SearchCriteria for find items
Container.Get<TestStack.White.UIItems.Button>("Verify").DoubleClick();
}
}
并这样称呼
var listbox = window.Get<RibbonUIItem>(SearchCriteria.ByText("Verify"));
但这仍然不返回任何项目或任何项目。
有人可以帮我指出正确的方向吗?