modal-dialog - UIAutomation - 如何使用 windowopendeventevent 处理程序绕过模态对话框阻塞?

标签 modal-dialog microsoft-ui-automation

我正在尝试为我们的一个产品构建一个自动化测试框架。一些测试用例涉及在模态对话框中执行自动化。但是,模态对话框会阻止 UIAutomation 代码的执行。换句话说,如果我有一个由 UIAutomation 打开的模态对话框,在我关闭模态对话框之前什么都不会发生。

为了在模式对话框显示时执行 UIAutomation 代码,我一直在尝试注册一个 windowopenedevent 处理程序,它在模式对话框打开时捕获它,这样我就可以在 windowopenedevent 处理程序中执行其余的测试。但是,处理程序根本没有捕获事件。我不知道哪里出了问题,有什么建议吗?

也欢迎针对此场景的其他解决方法。

最佳答案

我遇到过几次,通常是在浏览器测试中。

我所做的是这样的:

>> before taking the action that causes the modal dialog to show up:
   >> start another thread (OR) launch a script asynchrounously
   >> then take the action

>> In the other thread or script:
    >> Sleep for 5 seconds or so
    >> Activate the dialog
    >> send keystrokes or call UI auto methods to dismiss the dialog

一旦对话框关闭,您的测试应该解除阻塞。

这一直对我有用。

关于modal-dialog - UIAutomation - 如何使用 windowopendeventevent 处理程序绕过模态对话框阻塞?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12648165/

相关文章:

javascript - 模态关闭时执行函数(附有 Plunker)

html - 单击图标时打开的模态窗口

c# - UIA 自定义条件

modal-dialog - _NET_WM_STATE_MODAL 的预期行为是什么?

c# - Xamarin Forms - 从不从 ContentPage 继承的类中查找 App 的当前页面

javascript - 用 Foundation-5 显示模式替换 JavaScript Confirm

.net - 使用 Microsoft UI Automation 获取所有 Firefox 打开的 URL

ui-automation - UIA:从控件类型名称(字符串)获取ControlType

c# - 我应该使用 AutomationPeer 还是 AutomationElement?或两者?

user-interface - 使用 pywinauto 检查复选框不起作用