-->

Unable to click button using pywinauto on a specif

2019-08-09 21:39发布

问题:

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.