WPF UI 自动化 - 在单击 TabControl 区域之前,控件树不会被填充
我正在使用 Microsoft UI 自动化库为 WPF 应用程序执行 UI 自动化,效果很好。
然而,我的应用程序在 TabControl 中有四个屏幕。即使当我通过代码单击选项卡项时,其子控件树也不会填充。我能看到的唯一控件是“拇指”控件。当我用 UISpy 查看控制树时,也会发生同样的情况。
但是,如果单击该窗口,则会出现所有控件。作为解决方法,我通过代码模拟鼠标单击并且它有效。我想知道是否有更好的方法。
I am doing a UI automation for a WPF application using the Microsoft UI Automation library and it works well.
However my app has four screens in a TabControl. Even when I click the tab item through code its child control tree isnt populated. The only control I can see is the "thumb" Control. Same happens when I see the control tree with UISpy.
However if the window is clicked then all the controls appear. As a Workaround I am simulating a mouseclick through code and it works. I wanted to know if there is some better way of doing it.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我遇到了类似的问题。发生的情况是在线程上检索一些数据,并且在生成自动化对等点时未生成控件。我建议,如果您有权访问应用程序的代码库,您将尝试自动检查是否正在使用线程。在我的具体情况下,这是因为 BeginInvokes 用于检索数据,我将它们切换到 Invokes 并且工作正常。
另外,据我所知,鼠标悬停时显示控件的原因是工具提示生成了弹出窗口并导致自动化对等点更新。
I ran into a problem similar to this. What was happening was some data was being retrieved on threads and the controls were not generated at the point automation peers were generated. I would suggest if you have access to the code base for the application you are attempting to automate looking into whether threading is being used. In my specific case it was because BeginInvokes were used to retrieve the data, I switched them to Invokes and it worked fine.
Also from what I could tell the reason the controls were being show on mouse over was because the tool tip generated a popup and caused the automation peers to be updated.
如果可行的话,为什么不使用鼠标事件单击控件呢?
(现在,如果您仍然遇到这个问题..)
如何模拟鼠标点击在 C# 中?
Why don't you click the control using mouse events if that is what works.
(Now, if you still are having that problem..)
How to simulate Mouse Click in C#?