Below is my code :
1.app = Application (backend="uia").start("notepad.exe")
2.app.UntitledNotepad.Edit.type_keys("Hello World!")
3.app.UntitledNotepad.menu_select("File–>SaveAs")
4.Sub=app.window(title_re="Save As", class_name="#32770")
5.Sub.Edit1.click()
When I executed the 5th line to enter file name for the text file, an error was occurred
pywinauto.findwindows.ElementNotFoundError
@saikarthik99 , you seem to be get confused between the main window and its childrens. Your code actually tries to find a top window with the title "Save As", while you should look for a dialog. See below my fix for your example. Notice that I try to get the child window of the "Untitled - Notepad".
from pywinauto import Application
app = Application (backend="uia").start("notepad.exe")
app.UntitledNotepad.Edit.type_keys("Hello World!")
app.UntitledNotepad.menu_select("File->SaveAs")
Sub=app.UntitledNotepad.child_window(title_re="Save As", class_name="#32770")
Sub.FileNameCombo.type_keys("temp_12345.txt")
Sub.Save.click()
Also refer to my debug session with an alternative approach preventing lookup only for top-level windows (notice the argument top_level_only=False) and how I tried to figure out my next steps
ipdb> res = app.UntitledNotepad.menu_select("File->SaveAs")
ipdb> pp res
None
ipdb> res = app.UntitledNotepad.child_window(title_re="Save As", class_name="#32770", top_level_only=False)
ipdb> pp res
<pywinauto.application.WindowSpecification object at 0x000000179EAAB898>
ipdb> res.Edit1
<pywinauto.application.WindowSpecification object at 0x000000179EAB4470>
ipdb> res.Edit1.exists()
True
ipdb> res.Edit1.click()
*** AttributeError: Neither GUI element (wrapper) nor wrapper method 'click' were found (typo?)
ipdb> res.Edit1.draw_outline()
ipdb> res.FileName.draw_outline()
ipdb> res.FileNameEdit.draw_outline()
ipdb> res.FileNameCombo.draw_outline()
ipdb> res.FileNameCombo.type_keys("temp.txt")
<uia_controls.ComboBoxWrapper - 'File name:', ComboBox, 3713039552781460681>
ipdb> res.Save.click()
<uia_controls.ButtonWrapper - '', Button, 3713039552876722881>
ipdb>
Most helpful comment
@saikarthik99 , you seem to be get confused between the main window and its childrens. Your code actually tries to find a top window with the title "Save As", while you should look for a dialog. See below my fix for your example. Notice that I try to get the child window of the "Untitled - Notepad".
Also refer to my debug session with an alternative approach preventing lookup only for top-level windows (notice the argument
top_level_only=False) and how I tried to figure out my next steps