teststack white在登录窗口后获取主窗口 [英] teststack white get the main window after the login window

查看:195
本文介绍了teststack white在登录窗口后获取主窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Teststack white自动化Windows应用程序,当前的问题是登录主应用程序后,white似乎找不到新窗口.

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

推荐答案

所以我弄清楚了登录到应用程序后发生了什么,新的进程ID代替了旧的进程ID,所以我使用了Application.Attach()方法要获取新的应用程序",attach方法将PID作为参数,可以使用以下方法Process.GetProcessesByName(),然后获取最终可以通过该方法的进程的ID.到attach方法.

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.

这篇关于teststack white在登录窗口后获取主窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆