teststack white get the main window after the login window

左心房为你撑大大i 提交于 2019-12-11 10:34:15

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!