I want to control a SaveFileDialog (WinForms) from UI Automation (for product testing).
In the SaveFileDialog, I want to set the folder to write to and press the "Save" button. I haven't been able to find the ID's of the controls.
I'm working with C# 6.0, and NUnit for running the tests. From .NET we use Framework 4.5.2.
Can someone shed a light on what the controls are named and maybe point to the source where they are defined? Your help is greatly appreciated!
Below you find the dialog code in product (code behind for the button that calls the SaveFileDialog):
var dialog = new SaveFileDialog
{
FileName = newDefaultFileName,
DefaultExt = extension,
Filter = String.Format("{1} files (*.{0})|*.{0}|All files (*.*)|*.*", extension, "ExcelML"),
FilterIndex = 1
};
if (dialog.ShowDialog() == true)
{
try
{
using (Stream stream = dialog.OpenFile())
{
......
}
}
catch (Exception e)
{
Logger.Error("Export(): an exception occurred");
}
}