Unable to click button using pywinauto on a specific window on Windows 8 or 10

那年仲夏 提交于 2019-12-24 14:53:07

问题


I am performing automation testing of an application using pywinauto.

It worked successfully for every window of the app, but for some reason it fails to click the buttons on the install wizard, on Windows 8 and Windows 10. It works on Windows 7.

Tested with

  • python 2.7.10.amd64
  • pywinauto 0.5.3
  • Windows 10 x64

I can get the button coordinates, text, and every other info, however I cannot perform any action on it (click, press key)

The error I get is:

File "C:\Python27\Lib\site-packages\pywinauto\controls\HwndWrapper.py", line 900, in ClickInput self, button, coords, double, wheel_dist = wheel_dist, use_log = use_log, pressed = pressed, absolute = absolute)  
File "C:\Python27\Lib\site-packages\pywinauto\controls\HwndWrapper.py", line 1778, in _perform_click_input  win32api.SetCursorPos((coords[0], coords[1])) pwintypes.error: (0, 'SetCursorPos', 'No error message is available')

Thanks!


回答1:


It looks like you're trying to click on UAC confirmation window. You can do nothing with it from any script at all. Please disable UAC (to zero level) on your Win8/Win10 machines. This is the only way for install/uninstall GUI automation.

Python process must run as administrator of course.

BTW, some installers allow silent modes (msiexec.exe /i [MSI_path] or setup.exe /S for NullSoft (NSIS) installers). Of course it's not the case if you're testing an installer GUI itself.



来源:https://stackoverflow.com/questions/33254091/unable-to-click-button-using-pywinauto-on-a-specific-window-on-windows-8-or-10

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!