print_control_identifiers() error in pywinauto

5.5k views Asked by At

I am using pyautowin in WIN10, and I want to open a secure app to generate passcode. But after i find a window of app in script, the print_control_identifiers() function pops error, I'm not sure where goes wrong. Error Window? No controls in app? Please look into below errors.

Code like this:

from pywinauto.application import Application
app=Application()
app.start('C:\Program Files (x86)\RSA SecurID Software Token\SecurID.exe')
RSA=app.window_(title='000131843108 - RSA SecurID Token')
print RSA
print RSA.print_control_identifiers()

Error like this:

2016-12-30 11:54:01,525 INFO: Imported existing <module 'comtypes.gen' from         'C:\Python27\lib\site-packages\comtypes\gen\__init__.pyc'>
2016-12-30 11:54:01,526 INFO: Using writeable comtypes cache directory: 'C:\Python27\lib\site-packages\comtypes\gen'  
<pywinauto.application.WindowSpecification object at 0x039EA670>
Traceback (most recent call last):
  File "C:/New folder/ConnectVPN.py", line 7, in <module>
    print RSA.print_control_identifiers()
  File "C:\Python27\lib\site-packages\pywinauto\application.py", line 569, in print_control_identifiers
    this_ctrl = self.__resolve_control(self.criteria)[-1]
  File "C:\Python27\lib\site-packages\pywinauto\application.py", line 239, in __resolve_control
    raise e.original_exception
pywinauto.findwindows.ElementNotFoundError: {'process': 4064, 'backend': u'win32', 'title': '000131843108 - RSA SecurID Token'}

My app is like:

enter image description here

1

There are 1 answers

3
Vasily Ryabov On

Is your app starting slowly? If it takes more than 5 seconds, the main window may not exist yet and the exception is raised. Just use RSA.wait('ready', timeout=10) to make sure the window exists before print_control_identifiers().