I do automated testing and get a file dialog. I want to choose a file from the windows open file dialog with python or selenium.
NOTE: The dialog is given by an other program. I don't want to create it with Tkinter.
The Window looks like:
.
How to do this?
解决方案
Consider using the pywinauto package. It has a very natural syntax to automate any GUI programs.
Code example, opening a file in notepad. Note that the syntax is locale dependent (it uses the visible window titles / control labels in your GUI program):
from pywinauto import application
app = application.Application().start_('notepad.exe')
app.Notepad.MenuSelect('File->Open')
# app.[window title].[control name]...
app.Open.Edit.SetText('filename.txt')
app.Open.Open.Click()