检查Windows应用程序是否正在运行(不是进程) [英] Check if Windows Application is running (not process)

查看:131
本文介绍了检查Windows应用程序是否正在运行(不是进程)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望在自动化测试开始时检查应用程序是否打开.我可以通过执行以下操作来检查该进程是否正在运行

I am hoping to check at the beginning of an automated test if an application is open. I can check if the process is running by doing the following

foreach (Process proc in Process.GetProcesses()) 
{
    if (proc.ProcessName.Contains(name))
    {
        return true;
    }
}

但是,我要查找的过程大约在应用程序实际打开之前大约一分钟启动,并且可以被测试方法(其启动速度非常慢的应用程序)所使用.上面的代码示例查看了所有正在运行的Windows进程,但是我想知道,除了查看正在运行的Windows应用程序之外,是否有一种方法可以执行类似的方法?

However, the process I want to find starts up about a minute before the application actually opens and is ready to be used by the test methods (its a very slow starting application). The above code sample looks at all windows processes running, but I am wondering, is there a way to do a similar method but to look at windows applications running?

推荐答案

uITestControl.Exists为我完成了窍门.

此方法将返回一个布尔值,该值对应于正在打开的应用程序窗口的存在.这样可以创建一个if语句,如果尚未打开该应用程序,则可以打开该应用程序;如果已经打开,则不执行任何操作.

This method will return a boolean value corresponding to the existence of the application window being open. This allows an if statement to be created that can open the application if not already open, or do nothing if its already open.

这篇关于检查Windows应用程序是否正在运行(不是进程)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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