【发布时间】:2015-11-13 03:20:22
【问题描述】:
我正在学习使用 TestStack 的 White 来自动化 Windows 应用程序。我正在尝试通过使用路径“文件>>项目>>新建...”浏览应用程序的菜单项来自动创建一个新项目到目前为止,我已经获得了自动执行“文件>>项目”的功能,但它出错了退出“New...”,因为它“无法获取(ControlType=button 或 ControlType=check box),AutomationId=New...”。我用来从中提取 UI 信息的工具是 Visual UI Automation Verify。
源代码:
static void Main(string[] args)
{
string prog = @"C:\Program Files\CounterTack\Responder\Responder.exe";
TestStack.White.Application app = TestStack.White.Application.Launch(prog);
Window window = app.GetWindow(SearchCriteria.ByText("Responder® Professional Edition for Windows"),
TestStack.White.Factory.InitializeOption.WithCache);
window.WaitWhileBusy();
var cFile = window.MenuBar;
string[] path = { "File", "Project"};
cFile.MenuItem(path).Click();
Button cNew = window.Get<Button>("New...");
cNew.Click();
}
我已经尝试过:
var cFile = window.MenuBar;
string[] path = { "File", "Project", "New..."};
cFile.MenuItem(path).Click();
但是由于“新建...”不是菜单项,因此我也会收到错误消息。关于如何单击“新建..”按钮的任何想法/资源?
【问题讨论】:
-
您能否发布来自检查的新按钮属性的屏幕截图?
标签: c# ui-automation white-framework