无法执行Mouse.Click [英] Unable to perform Mouse.Click

查看:96
本文介绍了无法执行Mouse.Click的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

错误

Microsoft.VisualStudio.TestTools.UITest.Extension.FailedToPerformActionOnBlockedControlException:另一个控件正在阻止控件。请使阻止的控件可见,然后重试操作。其他详细信息:


TechnologyName:  'MSAA'

ClassName:  'WindowsForms10.Window'

ControlType:  '窗口'

实例:  '2'

Microsoft.VisualStudio.TestTools.UITest.Extension.FailedToPerformActionOnBlockedControlException: Another control is blocking the control. Please make the blocked control visible and retry the action. Additional Details:
TechnologyName:  'MSAA'
ClassName:  'WindowsForms10.Window'
ControlType:  'Window'
Instance:  '2'

代码:

UITestControl usernameControl = new UITestControl(){TechnologyName =" MSAA" }; b $ b            usernameControl.SearchProperties.Add(WpfEdit.PropertyNames.ControlType," Edit");

            usernameControl.SearchProperties.Add(WpfEdit.PropertyNames.FriendlyName," txtUserName");

            usernameControl.SearchProperties.Add(WinEdit.PropertyNames.ControlName," txtUserName");

            usernameControl.SearchProperties.Add(WinEdit.PropertyNames.ClassName," WindowsForms10.Window.b.app.0.392a42d_r51_ad1");

       &NBSP ;  

            usernameControl.Find();

            int count1 = usernameControl.FindMatchingControls()。Count;

            Console.WriteLine(count1);

            usernameControl.DrawHighlight(); //这突出显示了所需的文本框
UITestControl usernameControl = new UITestControl() { TechnologyName = "MSAA" };
            usernameControl.SearchProperties.Add(WpfEdit.PropertyNames.ControlType, "Edit");
            usernameControl.SearchProperties.Add(WpfEdit.PropertyNames.FriendlyName, "txtUserName");
            usernameControl.SearchProperties.Add(WinEdit.PropertyNames.ControlName, "txtUserName");
            usernameControl.SearchProperties.Add(WinEdit.PropertyNames.ClassName, "WindowsForms10.Window.b.app.0.392a42d_r51_ad1");
          
            usernameControl.Find();
            int count1 = usernameControl.FindMatchingControls().Count;
            Console.WriteLine(count1);
            usernameControl.DrawHighlight(); //This highlights the desired text box

推荐答案

亲爱的朋友,

欢迎来到MSDN论坛。

Welcome to MSDN forum.

我可以通过此代码询问您身边的号码:

May I ask the number you got in your side from this code:

   ;      int count1 = usernameControl.FindMatchingControls ()。Count;

         Console.WriteLine(count1);

        int count1 = usernameControl.FindMatchingControls().Count;
        Console.WriteLine(count1);

如果超过1 ,获取错误就不足为奇了。

if it's more than 1, it won't be surprising to get the error.

你有这些搜索属性,控件有独特的属性吗?与
自动设备ID 一样,如果可能,请将 ID 添加到搜索属性中。此外,由于Instance的值为2,您也可以使用它。

And you've got those search properties as above, is there an unique property the control has? Like the automation Id, please add the id to search properties if it's possible. Also, as the Instance's value is 2, you could use it as well.

顺便说一句,请尝试以下方法:

Btw, please try the method:

键盘 。SendKeys(usernameControl,{ENTER});

Keyboard.SendKeys( usernameControl,{ ENTER});

而不是 Mouse.Click() 并试一试。

instead of Mouse.Click()  and have a try.

请告诉我们结果。

期待您的回复。

 

 

祝你好运,

Fletcher


这篇关于无法执行Mouse.Click的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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