【问题标题】:Use Windows UIAutomation to tap on WPF TextBox使用 Windows UIAutomation 点击​​ WPF 文本框
【发布时间】:2022-01-01 06:13:49
【问题描述】:

我的 WPF Windows 桌面应用程序支持触控 - 所以当我点击 TextBox 时,键盘会弹出。 我正在尝试使用 Windows UIAutomation 为我的 WPF 应用程序编写测试。 我想使用 UIAutomation 在 TextBox 上“点击”并检查屏幕键盘是否真的弹出。 我该怎么做?我不想为此使用 WinAPI。 谢谢!

【问题讨论】:

  • 您可以尝试来自 SDK docs.microsoft.com/en-us/windows/win32/winauto/inspect-objects 的“Inspect”工具或更新的“Windows Accessibility Insights”accessibilityinsights.io/docs/en/windows/overview 并检查建议的模式并直接测试它们而无需编写任何单个一行代码。
  • @SimonMourier 感谢您提供 AccessibilityInsights 工具,它非常好!但是对于 TextBoxes,主要有 TextEditPattern 和 ValuePattern,我找不到任何与调用文本框上的点击以让 Windows 知道我愿意与此控件交互并启动虚拟键盘相关的内容。
  • 嗯,好像没有tap的模式……

标签: wpf desktop-application microsoft-ui-automation


【解决方案1】:

似乎 UIAutomation 无法点击/使用触摸。 我们将使用 WinAPI 来做这件事(已经测试过,它可以工作)。可以在这里找到解决方案: https://github.com/GuOrg/Gu.Wpf.UiAutomation/blob/c0109f39062e254b3eae40275730f0e9f7efce6e/Gu.Wpf.UiAutomation/Input/Touch.cs

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-09-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多