Hi, I was having issues with the SaveFile dialog working against a WPF application (played around with the initialization value, but it just never handled the dialog). So I decided on writing a function I could call when I needed it, that would handle the same thing.
Below is what I'm currently using, I pass it a string for the file path, as well as an Element to be clicked on (which is what causes the save dialog to appear).
I've tried playing around with waiting before/after clicking on the element to cause the dialog, but it just doesn't seem to consistently handle. Most of the times it works fine, and sometimes I find myself needing to manually intervene and close/reopen the dialog before it starts handling it. Any idea what would cause this? I haven't done any major waits before/after. Would increasing the time before clicking on the element help at all?
// Create the dialog handler.
SaveAsDialog saveDlg = SaveAsDialog.CreateSaveAsDialog(Manager.Current.ActiveApplication,
DialogButton.SAVE, filePath);
// Add the save dialog handler to the monitor, and start the monitor.
Manager.Current.DialogMonitor.AddDialog(saveDlg);
Manager.Current.DialogMonitor.Start();
System.Threading.Thread.Sleep(1000);
// Click on the element passed in that will create the dialog.
element.User.Click();
System.Threading.Thread.Sleep(1000);
// Wait until the dialog is handled, and then stop the monitor and remove the dialog.
saveDlg.WaitUntilHandled(30000);
Manager.Current.DialogMonitor.Stop();
Manager.Current.DialogMonitor.RemoveDialog(saveDlg);