【问题标题】:Ui automation testing right click menusUI自动化测试右键菜单
【发布时间】:2010-09-24 22:02:38
【问题描述】:

我正在尝试使用 ui 自动化对 wpf 应用程序进行自动化测试。我在模拟鼠标右键单击并在右键单击菜单中选择不同选项时遇到问题。有什么建议吗?

我在运行其他使用 ui 自动化编写的测试时也遇到了问题。因为如果我没有打开 UISpy 并且所有程序都最小化,他们只是不想开始。

【问题讨论】:

    标签: wpf testing user-interface automation


    【解决方案1】:

    通过大量浏览,我找到了这个解决方案。它可能对其他人有帮助:UI Automation in Silverlight

    只添加了简单的右键代码

    public static class Mouse
        {
    
            private const UInt32 MouseEventLeftDown = 0x0002;
            private const UInt32 MouseEventLeftUp = 0x0004;
            private const UInt32 MouseEventRightDown = 0x0008;
            private const UInt32 MouseEventRightUp = 0x00010;
    
    
            [DllImport("user32.dll")]
    
            private static extern void mouse_event(UInt32 dwFlags, UInt32 dx, UInt32 dy, UInt32 dwData, IntPtr dwExtraInfo);
    
    
    
            public static void Click()
            {
                mouse_event(MouseEventLeftDown, 0, 0, 0, IntPtr.Zero);
                mouse_event(MouseEventLeftUp, 0, 0, 0, IntPtr.Zero);
                Thread.Sleep(100);
            }
    
            public static void RightClick()
            {
                mouse_event(MouseEventRightDown, 0, 0, 0, IntPtr.Zero);
                mouse_event(MouseEventRightUp, 0, 0, 0, IntPtr.Zero);
                Thread.Sleep(100);
    
            }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-11-24
      • 1970-01-01
      • 1970-01-01
      • 2021-01-01
      • 2010-12-16
      相关资源
      最近更新 更多