1

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'])'
  • First you have to use Application(backend=“uia”) for Qt app. Second the WireShark example in the main repo could be helpful as a reference. menu_select() won’t work, but there is another way. – Vasily Ryabov Jul 23 '19 at 18:55
  • I have looked at the WireShark example and it did help a lot. I have been able to select 'file' and click on 'open case'. Right now I am having difficulty typing in a filename and clicking on buttons like "This PC". I was wondering, how does the `win = app[]` command work and how does ` child = win[]` work? What do you type between the brackets, and what do they do exactly? – Arsha Mamoozadeh Jul 24 '19 at 16:28
  • This is all described in the Getting Started Guide if you read it carefully. – Vasily Ryabov Jul 24 '19 at 19:25

0 Answers0