jpg
jpg

Reputation: 11

pywinauto menu_select() method throws {TimeOutError} time out from wait_untill

I want to click on the desktop application menubar File -> New -> New All option to open the new file by using the pywinauto menuselect method like this: main.menu_select("File->New->NewAll"). But it throws the error after clicking on the File option in Menu bar. It is not able to click on New option and then New All. The desktop app is build up using Qt technology. Action to be done using menu_select()

I have the method as below:

from pywinauto.application import Application
app = Application(backend="uia").start(r"C:\Program Files\abc\abc.exe", timeout=50)
app.window(title_re=".*abc*.").wait('ready visible', timeout= 50, retry_interval=5)
main = app.window(title_re=".*abc*.")
main.menu_select("File->New->NewAll")

Logs:

File "C:\Users\abc\AppData\Local\Programs\Python\Python39\lib\site-packages\pywinauto\controls\uiawrapper.py", line 723, in menu_select menu.item_by_path(path, exact).select() File "C:\Users\abc\AppData\Local\Programs\Python\Python39\lib\site-packages\pywinauto\controls\uia_controls.py", line 1032, in item_by_path timings.wait_until( File "C:\Users\abc\AppData\Local\Programs\Python\Python39\lib\site-packages\pywinauto\timings.py", line 375, in wait_until raise err E

main.print_control_identifiers() does not show the menubar controls such as File, Edit, Tools etc. So separate click on the File and then New and New All can not be done.

What would be the alternate approach to click on the menu bar and sub menu option using pywinauto or python? How can I increase the timeout so that I can use the workaround and it does not throw time out error after File is clicked and wait for New to be clicked?

Upvotes: 1

Views: 478

Answers (1)

Dego
Dego

Reputation: 11

I also have some issue when I tried with notepad.exe because of I used like open application as app = Application(backend="uia").start("notepad",timeout=15) .

So I did change my code to like below.

from pywinauto.application import Application
app = Application().start("notepad",timeout=15)
app.UntitledNotepad.menu_select("Help -> About Notepad")
app.aboutNotepad.OK.click()

Upvotes: 0

Related Questions