yinkaisheng / Python-UIAutomation-for-Windows

🐍Python 3 wrapper of Microsoft UIAutomation. Support UIAutomation for MFC, WindowsForm, WPF, Modern UI(Metro UI), Qt, IE, Firefox, Chrome ...
Apache License 2.0
2.5k stars 477 forks source link

uiautomation _ctypes.COMError: (-2147220991, '事件无法调用任何订户', (None, None, None, 0, None)) #200

Open qinaksd opened 2 years ago

qinaksd commented 2 years ago

use a wpf program in second time, the errror occurs。 the code is following:

ports = app.ComboBoxControl(AutomationId="cbPorts") dev = select_port(34952) result = uiautomation.WaitForExist(ports, 30) if result == True: ports.Select(dev) the error about the control: E:\ProgramData\Anaconda3\envs\python32\lib\site-packages\uiautomation\uiautomation.py:8039: in WaitForExist return control.Exists(timeout, 1) E:\ProgramData\Anaconda3\envs\python32\lib\site-packages\uiautomation\uiautomation.py:6418: in Exists control = FindControl(self.searchFromControl, self._CompareFunction, self.searchDepth, False, self.foundIndex) E:\ProgramData\Anaconda3\envs\python32\lib\site-packages\uiautomation\uiautomation.py:8353: in FindControl for child, depth in WalkControl(control, findFromSelf, maxDepth): E:\ProgramData\Anaconda3\envs\python32\lib\site-packages\uiautomation\uiautomation.py:8225: in WalkControl child = control.GetFirstChildControl()


self = <uiautomation.uiautomation.WindowControl object at 0x03925FA0>

def GetFirstChildControl(self) -> 'Control':
    """
    Return `Control` subclass or None.
    """
  ele = _AutomationClient.instance().ViewWalker.GetFirstChildElement(self.Element)

E _ctypes.COMError: (-2147220991, '事件无法调用任何订户', (None, None, None, 0, None)) have no idea , wish your reply, thankyou

sharfyhoo commented 2 years ago

这个问题我也有遇到过,可能是某个隐形弹窗,重点留意一下,可以加几秒的延时等弹窗自动关掉,或者做异常处理。

qinaksd commented 2 years ago

感谢回复

在 2022-04-19 20:40:45,"sharfyhoo" @.***> 写道:

这个问题我也有遇到过,可能是某个隐形弹窗,重点留意一下,可以加几秒的延时等弹窗自动关掉,或者做异常处理。

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

yuanweihuaskhb commented 2 years ago

我也遇到了,但失败时的截图有时没有隐形窗口,有时有(是个加载转圈,转圈时是控件是可以点击的),一般点击压测一段时间就会出现,概率还不低呢 2022-07-25-21-22-02 - test_other.py - test_other - click2 - 72 - INFO - 9、点击质控 2022-07-25-21-22-06 - conftest.py - conftest - pytest_runtest_makereport - 86 - INFO - 测试结果<TestReport 'testcase/testcase_common/test_other.py::TestOther::test_02' when='call' outcome='failed'> 2022-07-25-21-22-06 - conftest.py - conftest - pytest_runtest_makereport - 94 - ERROR - 测试【call】出现失败 2022-07-25-21-22-07 - conftest.py - conftest - pytest_runtest_makereport - 97 - ERROR - 失败截图~~~~~D:\project_python\pythonProject\log\20220725_190300\test_other\test_02\fail.png FAILED [100%] testcase\testcase_common\test_other.py:110 (TestOther.test_02) Traceback (most recent call last): File "D:\project_python\pythonProject\testcase\testcase_common\test_other.py", line 126, in test_02 self.click2() File "D:\project_python\pythonProject\testcase\testcase_common\test_other.py", line 73, in click2 ControlInfo.quality_text.Click() File "D:\soft_install\python3.8.8\lib\site-packages\uiautomation\uiautomation.py", line 6542, in Click point = self.MoveCursorToInnerPos(x, y, ratioX, ratioY, simulateMove) File "D:\soft_install\python3.8.8\lib\site-packages\uiautomation\uiautomation.py", line 6503, in MoveCursorToInnerPos rect = self.BoundingRectangle File "D:\soft_install\python3.8.8\lib\site-packages\uiautomation\uiautomation.py", line 5906, in BoundingRectangle rect = self.Element.CurrentBoundingRectangle _ctypes.COMError: (-2147220991, '事件无法调用任何订户', (None, None, None, 0, None))