Thank you for your feedback about the documentation. I guess you have used the exposed APIs description
to find the shared solution. If you have found any other resources, please let me know.
In regards the current issue you have encountered in handling the dialog which opens a folder, I would like to share with you how Win32 dialogs can be handled
with the Testing famework.
You probably have noticed that the OpenFolderDialog is a bit different from the other Win32 dalogs and is not present in the above shared article. This is because its structure does not suppose providing directly a folder path to handle that. The dialog from the screenshot does not have any text field to pass a folder path and is being handled with clicks or key presses even when doing this manually.
Having that said, to be able to automate the actions against that dialog you will need to send desktop actions against the currently active element. In Test Studio you can accomplish that using the Desktop Manager and its KeyBoard manager class
. Then, similar to this example
, send the necessary keystrokes to navigate to the desired folder.
If we take the example from the screenshot, assuming the folder to choose is the selected one - Dokumente - you might need to press Tab key once or twice to change the focus on the OK button. Then pressing the Enter key will confirm the selected path. To cover the scenario correctly you can try first manually what is the combination of keyboard key presses to navigate to the desired folder and then change the focus on the OK button to confirm the selection.
Having the example from the screenshot the below code will select the first sub-folder under the root one, assuming the focus currently is on that root folder. And then confirm the selection. The sample code will look similar to that below:
// The focus is on the root folder. Pressing Enter will expand it
// Pressing the down arrow will move the active element to the first sub-folder in the expanded root folder
// Pressing Tab will change the focus to any of the buttons Ok, Cancel or Create new folder
// In this example I assume a single Tab press sets focus on the Ok button
// Pressing Enter confirm the selection
Of course, the above sample is based on assumptions as I am not aware of the exact consequences of key presses required and thus you will need to additionally adjust it. Please have in mind that for the above code you will need to add an assembly reference in the project to System.Windows.Forms.dll, as well as list a using statement to it.
I hope this will be helpful to you. Though, if you need further assistance, please let me know.