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

Save a File from a WPF-Application

1 Answer 109 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Mostafa
Top achievements
Rank 2
Mostafa asked on 22 Aug 2012, 12:06 PM
Hi Telerik Team, 

I am Facing Problems in Handling the Download Dialog in WPF-Application. All the exemples and solutions that i found, are talking about internet explorer & Browsers. I have a WPF-Application and tring to test the Feature: " Save and Load"

First
I need to save the state, than to load the state. The state will be save as an XML-File with the extension " xxx.playlist". The test studio can't handle this window dialiog (see figure).

I have tried to program the save action, but it is not working.

Here is my code:

 

[CodedStep(@"Click Save")]
        public void A022_001_SaveAndLoad_CodedStep2()
        {
            var settings = new Settings();
            settings.Wpf = new ArtOfTest.WebAii.Core.Settings.WpfSettings("\"C:\\Program Files (x86)\\ClipJOCKEY_Nexio\\ClipJOCKEY.exe\"");
            var manager = new Manager(settings);
            manager.Start();
            var theApp = manager.ActiveApplication;
            SaveAsDialog saveDlg = SaveAsDialog.CreateSaveAsDialog(manager.ActiveApplication, DialogButton.SAVE, "test");
            manager.DialogMonitor.AddDialog(saveDlg);
            Thread.Sleep(15000);
            manager.DialogMonitor.Start();
    
            // LeftClick on Item180Textblock
            Applications.ClipJOCKEYexe.ClipJOCKEY.Item180Textblock.User.Click(ArtOfTest.WebAii.Core.MouseClickType.LeftClick, 17, 25, ArtOfTest.Common.OffsetReference.TopLeftCorner, ArtOfTest.Common.ActionPointUnitType.Percentage, ((System.Windows.Forms.Keys)(0)));
 
            Thread.Sleep(15000);
            manager.DialogMonitor.Stop();
            Thread.Sleep(15000);
        }

 

 

The object manager.ActiveApplicationis is always in debugging initialized to zero. How can how can I initialize it? is that correct what I'm doing? Do you know the solution?

greeting and thanks
Mostafa

 

 

1 Answer, 1 is accepted

Sort by
0
Plamen
Telerik team
answered on 27 Aug 2012, 03:20 PM
Hello Mostafa,

When you are using a coded step there is no need to create a new Settings or Manager objects. You can simply use the existing ones. Also, there is no need to start or stop the Dialog Monitor, Test Studio will do that for you. The following code should be enough to handle the Save File dialog with a coded step:
SaveAsDialog saveDlg = SaveAsDialog.CreateSaveAsDialog(Manager.ActiveApplication, DialogButton.SAVE, "test");
 
Manager.DialogMonitor.AddDialog(saveDlg);
 
Applications.ClipJOCKEYexe.ClipJOCKEY.Item180Textblock.User.Click();
 
saveDlg.WaitUntilHandled(30000);

I have created a simple WPF application with Save File dialog and as you can see in this video. I was able to handle it both ways, via a regular recorded step and via a coded step. I have attached the sample project for your reference.

If you continue to have difficulty a local repro is necessary. Can you provide a copy of your WPF app, or ask your developers to create a small sample app that demonstrates the issue? If you deem that information too sensitive for a public forum, please attach it a support ticket (which is confidential) and reference this thread.

Regards,
Plamen
the Telerik team
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
Tags
General Discussions
Asked by
Mostafa
Top achievements
Rank 2
Answers by
Plamen
Telerik team
Share this question
or