我正在尝试为我们的一个产品构建一个自动化测试框架。一些测试用例涉及在模态对话框中执行自动化。但是,模态对话框会阻止 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/