Python-UIAutomation-for-Windows
Python-UIAutomation-for-Windows copied to clipboard
程序问题
我用unittest运行测试用例, 会出现这种错误ele = _AutomationClient.instance().ViewWalker.GetFirstChildElement(self.Element) _ctypes.COMError: (-2147024891, '拒绝访问。', (None, None, None, 0, None))
以管理员权限运行
以管理员权限运行
我也偶尔出现这个问题,使用的pytest,以管理员权限运行无效。
..\utils\win_ops.py:253: in create_folder is_item_exist = list_item.Exists(6, 1) C:\Python37\lib\site-packages\uiautomation\uiautomation.py:5846: in Exists if prev and not prev._element and not prev.Exists(maxSearchSeconds, searchIntervalSeconds): C:\Python37\lib\site-packages\uiautomation\uiautomation.py:5846: in Exists if prev and not prev._element and not prev.Exists(maxSearchSeconds, searchIntervalSeconds): C:\Python37\lib\site-packages\uiautomation\uiautomation.py:5846: in Exists if prev and not prev._element and not prev.Exists(maxSearchSeconds, searchIntervalSeconds): C:\Python37\lib\site-packages\uiautomation\uiautomation.py:5846: in Exists if prev and not prev._element and not prev.Exists(maxSearchSeconds, searchIntervalSeconds): C:\Python37\lib\site-packages\uiautomation\uiautomation.py:5846: in Exists if prev and not prev._element and not prev.Exists(maxSearchSeconds, searchIntervalSeconds): C:\Python37\lib\site-packages\uiautomation\uiautomation.py:5854: in Exists control = FindControl(self.searchFromControl, self._CompareFunction, self.searchDepth, False, self.foundIndex) C:\Python37\lib\site-packages\uiautomation\uiautomation.py:7679: in FindControl for child, depth in WalkControl(control, findFromSelf, maxDepth): C:\Python37\lib\site-packages\uiautomation\uiautomation.py:7561: in WalkControl child = lastControl.GetNextSiblingControl() C:\Python37\lib\site-packages\uiautomation\uiautomation.py:5741: in GetNextSiblingControl return Control.CreateControlFromElement(ele)
element = <POINTER(IUIAutomationElement) ptr=0x130b27910d0 at 130b3dfbe48>
@staticmethod
def CreateControlFromElement(element) -> 'Control':
"""
Create a concreate `Control` from a com type `IUIAutomationElement`.
element: `ctypes.POINTER(IUIAutomationElement)`.
Return a subclass of `Control`, an instance of the control's real type.
"""
if element:
controlType = element.CurrentControlType
E _ctypes.COMError: (-2147220991, '事件无法调用任何订户', (None, None, None, 0, None))
C:\Python37\lib\site-packages\uiautomation\uiautomation.py:5200: COMError
self = <uiautomation.uiautomation.ListItemControl object at 0x000002002CA77FC8>
@property
def ControlType(self) -> int:
"""
Property ControlType.
Return int, a value in class `ControlType`.
Call IUIAutomationElement::get_CurrentControlType.
Refer https://docs.microsoft.com/en-us/windows/desktop/api/uiautomationclient/nf-uiautomationclient-iuiautomationelement-get_currentcontroltype
"""
return self.Element.CurrentControlType
E _ctypes.COMError: (-2147220991, '事件无法调用任何订户', (None, None, None, 0, None))
D:\work\tools\Python\Python37\lib\site-packages\uiautomation\uiautomation.py:5365: COMError
I'm regularly getting this error too, as -2147220991 aka CONNECT_E_ADVISELIMIT. It appears to be related to a timeout, when the controled app is unresponsive for several seconds. Though i could not find any documentation on why exactly this error is generated, my workaround currently is handling the exception by trying the same call again...
在使用Navicat Premium 工具时该问题必现,这个问题是否有解决? element = _AutomationClient.instance().IUIAutomation.ElementFromPoint(ctypes.wintypes.POINT(x, y)) _ctypes.COMError: (-2147220991, '事件无法调用任何订户', (None, None, None, 0, None))