It is possible to automate interaction (but not necessarily record the same) with file dialogs across machines that have the same operating system but different file system layouts, and even across machines that have different operating systems (and therefore different file dialogs).
In case of nativeType() (which sends the key presses to whatever window which has the focus) this works because commonly file dialogs get the input focus into a text field for entering a file name or path when they appear on the screen.
The above automation approach works with most editions of Squish, but it does not provide any control over which widgets are currently available for input.
To make the file dialog interaction more robust — at the price of making it toolkit-specific, instead of the above approach, record the entering of a filename and a Return keypress (or OK or Open button click). For example:
|This workaround does not work with Qt 5.5.1 due to bug QTBUG-49782 in Qt itself.|
The following approach should work for most Squish editions because it does not require any object references. However, its successful use depends on two assumptions:
- The file dialog opens within the anticipated amount of time.
- After opening, the file dialog's filename input field has the keyboard focus.
|Mac OS X-specific|
By default Mac OS X file dialogs do not show a filename editing field by default. Nonetheless, this can be worked around: see [Example - Automating native Mac OS X file dialogs with nativeType()]