Python-UIAutomation-for-Windows
Python-UIAutomation-for-Windows copied to clipboard
方法 GetChildren() 的可靠性存疑
GetChildren() 实现中用到了 IUIAutomationTreeWalker::GetNextSiblingElement() 这个win32 API 。看microsoft的官网文档( 链接 https://docs.microsoft.com/en-us/windows/win32/api/uiautomationclient/nf-uiautomationclient-iuiautomationtreewalker-getnextsiblingelement )说,“ The structure of the Microsoft UI Automation tree changes as the visible UI elements on the desktop change. It is not guaranteed that an element returned as the next sibling element will be returned as the next sibling on subsequent passes.”我的理解是这个API并不保证第2次遍历控件树会得到相同结果。
这个问题的背景是在使用uiautomation 过程中,发现有个别控件用下标访问时访问失败,原因是下标变了。
不知道我的理解对不对,请问有谁可以帮忙解释一下吗?
calibrator_table = auto.TableControl(AutomationId='dataGridViewCalibrator') # 校准品表格 calibrator_table.GetChildren() 表格里内容会变化,多次获取表格子类.GetChildren(),后面几次获取到的还是上次的内容,没有实时更新 clear_log_ok = auto.PaneControl(AutomationId="btnOK") 页面弹窗的AutomationId不会变,Name会变化,但后面几次获取Name有时信息不正确,没有实时更新,还是上一次的内容