问题
I am working on automating a windows application using Teststack white, the current issues that I have is that after logging in the main application, white doesn't seems to find the new window.
var pathAp = appPath(path);
Application application = Application.Launch(pathAp);
Window window = application.GetWindow("login");
TextBox userName = window.Get<TextBox>("userName");
TextBox pass = window.Get<TextBox>("pass");
userName.Enter("user1");
pass.Enter("pass");
Button login = window.Get<Button>("login");
login.Click();
//now the program will wait and the main window will show up
Window mainWindow = application.GetWindow("main");
for some reason the program throws an error message saying that it can't find the window. any ideas guys thanks
回答1:
so I figured out what happened after logging in to the application the new process ID appears instead of the old one, so I used the Application.Attach() method to get hold of the new "Application", the attach method takes a PID as parameter, to get that you can use the following method, Process.GetProcessesByName(), and you can then get the ID of the process that can eventually pass it to the attach method.
来源:https://stackoverflow.com/questions/33532641/teststack-white-get-the-main-window-after-the-login-window