This is a migrated thread and some comments may be shown as answers.

SaveAsDialog Implementation

1 Answer 58 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Aaron
Top achievements
Rank 1
Aaron asked on 06 Apr 2017, 02:48 PM

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);

1 Answer, 1 is accepted

Sort by
0
Elena
Telerik team
answered on 11 Apr 2017, 08:00 AM
Hi Aaron,

Thank you for sharing detailed description of the inconsistent behavior you have spotted. 

The reported issue is actually known for us but unfortunately it is also that inconsistent and could not be intended reproduced. To handle dialogs Test Studio relies on the Windows UI automation framework and obviously it sometimes fails for no obvious reason. 

I am sorry to admit that so far there isn't any reliable solution to the observed inconsistency. 

I hope this will be at least informative for you. Thanks for your understanding! 

Regards,
Elena Tsvetkova
Telerik by Progress
 
The New Release of Telerik Test Studio Is Here! Download, install,
and send us your feedback!
Tags
General Discussions
Asked by
Aaron
Top achievements
Rank 1
Answers by
Elena
Telerik team
Share this question
or