Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/260.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
c#-控制弹出窗口,Windows 10_C#_Automated Tests_Ui Automation - Fatal编程技术网

c#-控制弹出窗口,Windows 10

c#-控制弹出窗口,Windows 10,c#,automated-tests,ui-automation,C#,Automated Tests,Ui Automation,我对使用C#的UIAutomation有一个问题。 在Windows 10上,单击测试应用程序中的链接后,会显示弹出窗口,我无法控制它 下图: 我的代码如下: AutomationElement ele = null; while (ele == null) { try { ele = AutomationElement.RootElement.FindFirst(TreeScope.Subtree, new

我对使用C#的UIAutomation有一个问题。 在Windows 10上,单击测试应用程序中的链接后,会显示弹出窗口,我无法控制它

下图:

我的代码如下:

AutomationElement ele = null;
        while (ele == null)
        {
            try {
                ele = AutomationElement.RootElement.FindFirst(TreeScope.Subtree, new PropertyCondition(WindowPattern.IsModalProperty, true));


                Console.WriteLine(ele.Current.Name);

            } catch (NullReferenceException) {


            }

仅仅模拟回车键并不能解决这个问题?@GabrielDuarte它可以解决我的问题,但我应该使用线程。在等待弹出窗口的未知时间睡眠,然后模拟按键。这将是最后的解决办法。但我试图找到更合适(或正确)的方法来解决这个问题。对不起,我英语不好(