I am trying to do some ui automation for my research and it has been proving to be tricky. I am trying to launch a program, open a file, click on a few things, and then open another file. I have run into a few issues along the way. First, whenever the program launches, it launches a child window which is the window that I need to interact with, so I have to connect to that separately. I am not sure if I have successfully connected to the window so is there a way to check that? Second, in order to open the right file I was trying to use menu_select('File->Open Case')
but I get the error saying that "There is no menu"
.
I have tried using menu_select('File->Open Case')
, I tried using app.send_keys("^o")
, and I have tried dlg.File_tab.click()
. These attempts are commented out in my code. Each attempt gave a different error.
Here is all of my code.
import time
from pywinauto import application
app=application.Application()
app.start(r'c:\Program Files\ANSYS Inc\v191\CFX\bin\cfx5pre.exe', wait_for_idle=False)
time.sleep(5)
app.connect(title_re='CFX-Pre', class_name='QWidget')
time.sleep(5)
dlg = app.window(title_re='CFX-Pre',class_name='QWidget')
#app['QWidget'].menu_select("File->Open Case")
#app.send_keys("^o")
#dlg.File_tab.click()
With the menu_select I get this...
RuntimeError: There is no menu.
with send_keys I get this...
AttributeError: Neither GUI element (wrapper) nor wrapper method 'send_keys' were found (typo?)
with File_tab.click() I get this...
raise MatchError(items = name_control_map.keys(), tofind = search_text)
MatchError: Could not find 'File_tab' in 'dict_keys(['', 'QWidget', '0', '1', '2', 'QWidget0', 'QWidget1', 'QWidget2', '3', 'QWidget3', '4', 'QWidget4', '5', 'QWidget5', '6', 'QWidget6', '7', 'QWidget7', '8', 'QWidget8', '9', 'QWidget9'])'