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

Save Downloaded file

36 Answers 461 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Satyajeet
Top achievements
Rank 1
Satyajeet asked on 16 Jan 2012, 12:58 PM
Hi,

I am using the below code to save a file download dialog to a particular path.
Below is my code.

 

Manager.Settings.UnexpectedDialogAction = UnexpectedDialogAction.DoNotHandle; 
DownloadDialogsHandler handler = new DownloadDialogsHandler(ActiveBrowser, DialogButton.SAVE, @"D:\address.xls", Manager.Desktop); 
Manager.ActiveBrowser.WaitUntilReady(); 
Pages.abcd.FrameFrame1.DownloadlinkLink.Click(false);
handler.WaitUntilHandled(9000);

I am getting the attached exception and the file doesnot save.
It opens the SaveAs dialog and doesnot pick the given path and freezes.
Attached is the screenshot of steps performed to save.

Could you please help.

Thanks,
Satya

36 Answers, 1 is accepted

Sort by
0
Satyajeet
Top achievements
Rank 1
answered on 16 Jan 2012, 01:35 PM
Hi,

I found the solution and the download works fine now.
The file downlaods to the given path but the Download Complete dialogue box does not close.

I have handled this by below code, but does not work. I have also unchecked the checkbox.
IEDownloadCompleteDialog dlComplete = new IEDownloadCompleteDialog(ActiveBrowser, DialogButton.CLOSE, Manager.Desktop);

Please help.

Thanks,
Satya
0
Nitin
Top achievements
Rank 1
answered on 16 Jan 2012, 06:30 PM
Hi Satya

Which Browser you are Using, IE 8 or IE 9

How you Handled the Download Dialogs
I am facing the same issues in IE 9 

http://www.telerik.com/automated-testing-tools/community/forums/test-studio-express/automation-framework/unable-to-handle-the-download-dialog-in-ie-9.aspx 
 
Thanks
Nitin
0
Accepted
Anthony
Telerik team
answered on 16 Jan 2012, 06:59 PM
Hello Satya,

The initial code you posted is intended to work with IE8 and 9, however a regression was just discovered with IE8 where the final "Download Complete" window is not handled properly. You can track the PITS Issue here.

As a work-around in the meantime, you can revert to the old style of handling the download in three parts. Instead of using the dialog handler for part three (where the bug is), add code to press the Enter key instead:


Manager.LaunchNewBrowser(BrowserType.InternetExplorer);
  
string saveLocation = string.Format("address-{0:HH-mm-ss}.xls", DateTime.Now);
  
//Create dialogs
IEDownloadDialog part1 = newIEDownloadDialog(ActiveBrowser, DialogButton.SAVE, Manager.Desktop);
SaveAsDialog part2 = SaveAsDialog.CreateSaveAsDialog(ActiveBrowser, DialogButton.SAVE, @"C:\"+ saveLocation, Manager.Desktop);
  
//Exclude part 3
//IEDownloadCompleteDialog part3 = new IEDownloadCompleteDialog(ActiveBrowser, DialogButton.CLOSE, Manager.Desktop);
              
//Add each dialog to the monitor
Manager.DialogMonitor.AddDialog(part1);
Manager.DialogMonitor.AddDialog(part2);
//Manager.DialogMonitor.AddDialog(part3);
               
HtmlAnchor dlLink = Find.ByContent<HtmlAnchor>("Sample Address File");
dlLink.Click();
  
part1.WaitUntilHandled(5000);
part2.WaitUntilHandled(5000);
//part3.WaitUntilHandled(5000);
  
//Alternative handling of part 3
System.Threading.Thread.Sleep(5000);
Manager.Desktop.KeyBoard.KeyPress(System.Windows.Forms.Keys.Enter);


Kind regards,
Anthony
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Satyajeet
Top achievements
Rank 1
answered on 16 Jan 2012, 07:20 PM
Hi Anthony,
 
Thanks. The code works perfectly.

Satya.
0
Amos
Top achievements
Rank 1
answered on 16 Feb 2012, 05:05 PM
Hi, 
I have updated Test Studio with the last Release (TestStudio_2011_2_1413) but the bug about the final "Download Complete" window persists, is normal?
0
N1t1nA
Top achievements
Rank 1
answered on 17 Feb 2012, 06:58 AM
Hi Amos 

Which version of IE you are using,
use downloads dialogs Handler Class

DownloadDialogsHandler handler = new DownloadDialogsHandler(ActiveBrowser, DialogButton.SAVE, @"D:\address.xls", Manager.Desktop); 
//Click Event which initiates the Download Process
handler.WaitUntilHandled(30000);

Hope this Helps 
Thanks
Nitin



 
0
Amos
Top achievements
Rank 1
answered on 17 Feb 2012, 09:51 AM
Hi Nitin,

I use IE8 and I tested your code but the final "Download Complete" window remains open.



0
N1t1nA
Top achievements
Rank 1
answered on 17 Feb 2012, 10:36 AM
Hi Amos

Please Check your browser settings
http://www.telerik.com/automated-testing-tools/support/documentation/user-guide/configure-your-browser/internet-explorer.aspx

Also, you can Close this Download Complete by using Keyboard Actions,
Sort of Workaround.
Manager.Desktop.KeyBoard.KeyDown(Keys.Alt);
Manager.Desktop.KeyBoard.KeyPress(Keys.F4);
Manager.Desktop.KeyBoard.KeyUp(Keys.Alt);

-Nitin-
0
Amos
Top achievements
Rank 1
answered on 17 Feb 2012, 11:13 AM
My browser's settings are setted correctly .

I use your Workaround 

So in this release of TestStudio this bug is not really fixed?
0
N1t1nA
Top achievements
Rank 1
answered on 17 Feb 2012, 11:20 AM
Hi Amos

Yes, this seems to be, may be Support Guys put some light on this.

-Nitin-
0
Anthony
Telerik team
answered on 17 Feb 2012, 05:53 PM
Hello Amos,

We've discovered that certain machine configurations still leave the "Download complete" dialog open at the end of the test. We're investigating the issue and hope to have it resolved shortly.

In the meantime please use one of the work-arounds in this thread to handle the "Download complete" dialog.

All the best,
Anthony
the Telerik team
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
0
Satyajeet
Top achievements
Rank 1
answered on 19 Jun 2012, 01:49 PM
Hi Anthony,
I am trying to handle a file download dialogue. Am using the below code.
I would like to perform some ABC steps on the page and then handle File download diagloue and then perform some XYZ steps on the same page and then handle File download dialogue one after the other.

The file download handles perfectly for the first time saves the output to the specified folder, but when it comes to the second file handling dialogue, the file dilogue opens but it does not click on the Save button. It hover on the Save button, but does not perform the click opertaion on the Save button. The same code works for the first time and doesnt work for the second time.

Could you please help.

try
 -----ABC  code here------------------
IEDownloadDialog ieDialog = new IEDownloadDialog(ActiveBrowser, DialogButton.SAVE, Manager.Desktop);
Manager.DialogMonitor.AddDialog(ieDialog);
                  
SaveAsDialog saveExport;
 saveExport = SaveAsDialog.CreateSaveAsDialog(ActiveBrowser, DialogButton.SAVE, testRunDir + "\\" + "Snap" + ".pptx", Manager.Desktop);
  
                if (File.Exists(saveExport.SaveFileName))
                {
                    File.Delete(saveExport.SaveFileName);
                }
                Manager.DialogMonitor.AddDialog(saveExport);
  
                IEDownloadCompleteDialog dlComplete = new IEDownloadCompleteDialog(ActiveBrowser, DialogButton.CLOSE, Manager.Desktop);
                Manager.DialogMonitor.AddDialog(dlComplete);
  
                Manager.Settings.UnexpectedDialogAction = UnexpectedDialogAction.DoNotHandle;
                Manager.DialogMonitor.Start();
                Thread.Sleep(10000);
                 Pages.panelXYZ.OwnerBrowser.Actions.InvokeScript("document.getElementById('btnGo').click()");                
                ieDialog.WaitUntilHandled(50000000);
                 saveExport.WaitUntilHandled(50000000);
                Thread.Sleep(2000);
               Manager.Desktop.KeyBoard.KeyPress(System.Windows.Forms.Keys.Enter);
}
catch
{
}
try
{
 ----- XYZ code here------------------
  
 IEDownloadDialog ieDialogSnapSlicer = new IEDownloadDialog(ActiveBrowser, DialogButton.SAVE, Manager.Desktop);
 Manager.DialogMonitor.AddDialog(ieDialogSnapSlicer);                
SaveAsDialog saveSnapSlicer;
saveSnapSlicer = SaveAsDialog.CreateSaveAsDialog(ActiveBrowser, DialogButton.SAVE, testRunDir + "\\" + "SnapSlicer" + ".pptx", Manager.Desktop);
  
      if (File.Exists(saveSnapSlicer.SaveFileName))
                {
                    File.Delete(saveSnapSlicer.SaveFileName);
                }
                Manager.DialogMonitor.AddDialog(saveSnapSlicer);
  
 IEDownloadCompleteDialog dlCompleteSnapSlicer = new IEDownloadCompleteDialog(ActiveBrowser, DialogButton.CLOSE, Manager.Desktop);
 Manager.DialogMonitor.AddDialog(dlCompleteSnapSlicer);
  
Manager.Settings.UnexpectedDialogAction = UnexpectedDialogAction.DoNotHandle;
 Manager.DialogMonitor.Start();
Thread.Sleep(10000);
Pages.panelXYZ.OwnerBrowser.Actions.InvokeScript("document.getElementById('btnGo').click()");
 ieDialogSnapSlicer.WaitUntilHandled(50000000);
Thread.Sleep(2000);
saveSnapSlicer.WaitUntilHandled(50000000);
Thread.Sleep(2000);                
Manager.Desktop.KeyBoard.KeyPress(System.Windows.Forms.Keys.Enter);
  
}
catch
{
}


Regards,
Satya
0
Anthony
Telerik team
answered on 19 Jun 2012, 05:46 PM
Hello Satya,

Now that the original issue is resolved, you can use the DownloadDialogsHandler once again. It automatically handles all three download dialogs in sequence.

The following code successfully handles two downloads consecutively in version 2012.1.528:

Manager.Settings.UnexpectedDialogAction = UnexpectedDialogAction.DoNotHandle;
Manager.LaunchNewBrowser();
 
string saveLocation = string.Format("address-{0:HH-mm-ss}.xls", DateTime.Now);
DownloadDialogsHandler handler1 = new DownloadDialogsHandler(ActiveBrowser, DialogButton.SAVE, @"C:\1" + saveLocation, Desktop);
 
HtmlAnchor dlLink = Find.ByContent<HtmlAnchor>("Sample Address File");
dlLink.Click();
System.Threading.Thread.Sleep(2500);
handler1.WaitUntilHandled(30000);
 
System.Threading.Thread.Sleep(2500);
DownloadDialogsHandler handler2 = new DownloadDialogsHandler(ActiveBrowser, DialogButton.SAVE, @"C:\2" + saveLocation, Desktop);
dlLink.Click();
System.Threading.Thread.Sleep(2500);
handler2.WaitUntilHandled(30000);
 

All the best,
Anthony
the Telerik team
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
0
Satyajeet
Top achievements
Rank 1
answered on 21 Jun 2012, 06:17 PM
Hi Anthony,
As suggested by you, i also tried using DownloadDialogsHandler, but the same issue exists. The download dialogue handles for the first save dialogue perfectly, but when it moves to the second file download dialogue....it is unable to handle it and file download dialogue just stays on......it does not perform the click operation on the SAVE button.....i see that on the file download dialogue for the second time the CANCEL button is highlighted with blue border blinking and on the on the SAVE button i see a dotted border....i guess the mouse hover on SAVE button, but is unable to perform the click operation for the second time......if i manually click the save button when the file download dialogue stays on, it works good.....when i debug the code, the file download handles the second dialogue aswell.......it successfully handles two downloads consecutively when i debug the code and also when i manually perform the click on the SAVE button, but stays on when i run the application.
I am unable to figure out this strange behavior. i am stuck with this issue since couple of days. It would be very kind if you could please provide me a perfect solution.

FYI....in my application i am trying to handle 5 file download dialogues one after the other. i ALSO tried to keep the DownloadDialogsHandler in a seperate method and just call the method everytime....it just works for the first time as usual.....stays on when it comes to handle the second dialogue, if i manually click save button for second time, it again stays on when it comes to handle the third file download dialogue and so on..
Hope i have explained my issue in detail

Thanks,
Satya

0
Anthony
Telerik team
answered on 22 Jun 2012, 04:04 PM
Hello Satya,

Are you using version 2012.1.528 of the Framework where this issue is fixed? Have you tried the sample code I provided in my last response, which is written against a public site?

If you upgrade and continue to experience difficulty, please provide a complete code sample against a public site that demonstrates the issue.

Kind regards,
Anthony
the Telerik team
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
0
Aliluyko
Top achievements
Rank 1
answered on 03 Jan 2013, 06:26 PM
Hi,
Could you help with download toolbar in IE9??
I have one solution but it's doesn't stability.
I use Telerik_Testing_Framework_2012_2_1204_FREE_EDITION.
                        // for IE9
                        downloadLink.Click(true);

                        Thread.Sleep(3000); // to show download bar

                        WindowManager winManager = new WindowManager();
                        Process prc = _telerikManagerObj.ActiveBrowser.Window.OwnerProcess;
                        winManager.GetAllWindows(prc);

                        foreach (Window win in winManager.Items)
                        {
                            //if (win.ClassName == "DirectUIHWND")
                            if (win.ClassName == "Frame Notification Bar")
                            {
                                // relative position formula: xPos = frameWidth / 12 * 2 * -1.
                                // 12 - amount of buttons that could be placed in frame
                                // 2 - "Save As" button is second button from the right
                                // -1 - for negative offset
                                _telerikManagerObj.Desktop.Mouse.Click(MouseClickType.RightClick, win.Rectangle, new Point(win.Size.Width/12*2*-1, 7), OffsetReference.RightCenter);
                                Thread.Sleep(500);
                                // sometimes one click is not enough to set focus
                                _telerikManagerObj.Desktop.Mouse.Click(MouseClickType.RightClick, win.Rectangle, new Point(win.Size.Width/12*2*-1, 7), OffsetReference.RightCenter);
                                Thread.Sleep(500);
                                _telerikManagerObj.Desktop.KeyBoard.KeyPress(Keys.Down);
                                _telerikManagerObj.Desktop.KeyBoard.KeyPress(Keys.Down);
                                _telerikManagerObj.Desktop.KeyBoard.KeyPress(Keys.Enter);
                                break;
                            }
                        }

                        //start monitoring for download dialog with 5 sec delay
                        _systemHandler.ProcessDownloadDialog(pathForDownload);

Thanks.

0
Cody
Telerik team
answered on 03 Jan 2013, 08:16 PM
Hello Aliluyko,

It appears to me you may be taking the hard way to handling the standard IE download popup. We have a built-in download dialog handler that will do 90% of the work for you.

Regards,
Cody
the Telerik team
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
0
Aliluyko
Top achievements
Rank 1
answered on 03 Jan 2013, 09:29 PM
Hello Cody,

Does this solution work with toolbar, which was attached above?
Thanks.
0
Aliluyko
Top achievements
Rank 1
answered on 04 Jan 2013, 09:47 AM
Cody,

Solution, which was provided doesn't work with download toolbar.(Image of toolbar was attached).
Have you another solutions?
Thanks.
0
Mario
Telerik team
answered on 08 Jan 2013, 08:58 PM
Hi Aliluyko,

Here is a code sample and execution video of the download handler running against the IE9 'toolbar':

Settings.Current.UnexpectedDialogAction = UnexpectedDialogAction.DoNotHandle;
Manager.LaunchNewBrowser(BrowserType.InternetExplorer);
ActiveBrowser.NavigateTo("http://www.fiddlercap.com");
Element b = Find.ByAttributes("href=/dl/FiddlerCapSetup.exe");
string saveLocation = System.IO.Path.Combine("C:\\", "FiddlerCapSetup.exe");
DownloadDialogsHandler handler = new DownloadDialogsHandler(ActiveBrowser, DialogButton.SAVE, saveLocation, Desktop);
Actions.Click(b);
handler.WaitUntilHandled(20000);

Let me know if you have any followup questions.

All the best,
Mario
the Telerik team
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
0
Aliluyko
Top achievements
Rank 1
answered on 10 Jan 2013, 11:00 AM
Hi Mario,
Thanks.
0
Aliluyko
Top achievements
Rank 1
answered on 21 Jan 2013, 04:11 PM
Hi Mario,

I have issue with handling download dialog.
During download I get multiline toolbar. He more width than standard.
Could you help with this issue?
I use following code:
                                                                     ...
                DownloadDialogsHandler downloadDialogsHandler = new DownloadDialogsHandler(downloadLink.OwnerBrowser, DialogButton.SAVE, saveLocationFilePath, _telerikManagerObj.Desktop);
                //raise download dialog
                downloadLink.Click(true);
                try
                {
                    downloadDialogsHandler.WaitUntilHandled(GlobalConst.Win32DialogTimeout);
                    _telerikManagerObj.DialogMonitor.Stop();
                }
                                                               ...
Thanks,

0
Mario
Telerik team
answered on 24 Jan 2013, 04:51 PM
Hi Aliluyko,

I apologize for the delay in getting back to you on this.

Looking at your images, these IE dialog's appear to be nearly identical with one main difference. From what I can tell, the file being downloaded in the 'ExportIssue.png' dialog has a longer name which distorts the button locations slightly. However this does not affect the dialog handler, using the same code as before on a downloadable file with a long enough name to widen the download dialog still works as expected for me.

Kind regards,
Mario
the Telerik team
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
0
Raj
Top achievements
Rank 1
answered on 30 Jun 2014, 05:13 PM
Hi Mario,

How do I handle the dialog box in IE 11? I tried all the above methods but none of them seem to work with download dialogs in IE 11. Any suggestions?
0
Cody
Telerik team
answered on 03 Jul 2014, 02:59 AM
Hi Raj,

First I must ask what version of Test Studio, or our framework do you currently have installed? We used to not have support for IE 11, but did add it about a year ago. I just need to verify you are using a version that is compatible with IE 11.

Regards,
Cody
Telerik
 
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
 
0
Ganga
Top achievements
Rank 1
answered on 07 Jul 2014, 10:01 PM
Hi Cody,

I can able to give some information based on your question.

I am using latest TestingFramework_2014_2_618 and my tests run on IE 10 & IE 11 as well as Chrome. The download test always successful on Chrome, but IE 10 & IE 11 failed 90% of the time.

The download handler able interact with Save as dialog and save the file successfully all the time in IE 10 & IE 11, but toolbar is failed closes after file saved.  I was playing with my code, but still no luck. I was able to run the below mention code in IE 10 & 11 10% of the time.

Please note this, all my test are executing successfully,  if I comment it out // dlgHandler.WaitUntilHandled(18000000);.  What is happening, file saved successfully and rest of the steps executed successfully all the time in IE 10 or IE 11. 

I tested with Windows 7, 8 & 2012....


My Code:
public static void InvokeDownload(Element element)
{
       // Create the filename, save to Log folder for current run, file name to be
       // DateTime.Now.Ticks plus original file extension which will be added automatically 
       //string fileName = String.Format("Download_{0}{1}{2}", DateTime.Now.Hour, DateTime.Now.Minute, DateTime.Now.Second);
       string fileName = String.Format("File_{0}{1}{2}", DateTime.Now.Hour, DateTime.Now.Minute, DateTime.Now.Second);
       string logPath = Manager.Current.Settings.LogLocation;
       string filePath = System.IO.Path.Combine(logPath, fileName);

       HtmlControl control = element.As<HtmlControl>();
            
        //Create dialogs
        DownloadDialogsHandler dlgHandler = new DownloadDialogsHandler(Manager.Current.ActiveBrowser, DialogButton.SAVE,                   fileName, Manager.Current.Desktop);
                                    
        try
        {
               //Clicking on button/link ‘Save Dialog’ will open     
                control.Click(true);

                //Wait until dialog is handled
               dlgHandler.WaitUntilHandled(18000000);
               
               
              // Search file path for file starting with fileName to find physical fileName
              string[] files = System.IO.Directory.GetFiles(logPath);
              foreach (string file in files)
              {
                    if (System.IO.Path.GetFileName(file).StartsWith(fileName, StringComparison.OrdinalIgnoreCase))
                    {
                        fileName = file;
                        break;
                    }
              }
              // Log to manager
              Manager.Current.Log.WriteLine(String.Format("File \"{0}\" downloaded.", fileName));
        }
        catch
        {
               //Manager.Current.ActiveBrowser.Window.SetFocus(); 
                WriteLog(element, "handling dialog");
         }
         finally{}          
}
 



0
Ganga
Top achievements
Rank 1
answered on 07 Jul 2014, 10:03 PM
Hi Cody,

I forget to attached image... Please see the attached image....

Cheers
Ganga S
0
Cody
Telerik team
answered on 10 Jul 2014, 03:59 PM
Hi Ganga,

First I can confirm that TestingFramework_2014_2_618 includes support for IE 10 & 11.

I was able to run the below mention code in IE 10 & 11 10% of the time.

Maybe the browser is not configured right. Make sure that "Notify me when my downloads are complete." is checked as documented near the bottom of this page.

Regards,
Cody
Telerik
 
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
 
0
Ganga
Top achievements
Rank 1
answered on 13 Jul 2014, 09:32 PM
Hi Cody,

Thanks for the confirmation. 

My IE web browser configured according the documentation.

Cheers
Ganga S
0
Cody
Telerik team
answered on 15 Jul 2014, 07:22 PM
Hello Ganga,

All right. Let's find out of this problem is specific to your application or your computer. Please try running the attached test, which downloads a file from a different website. This test works 100% of the time on my computer. How well does it work on yours?

Regards,
Cody
Telerik
 
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
 
0
Ganga
Top achievements
Rank 1
answered on 15 Jul 2014, 11:46 PM
Hi Cody,

I test works 100% of the time on my computer with "Unexpected dialog encountered. Taking no action." error. 

I have noticed, when I run the test on public web site, I got a different download dialog, but If I run the test on our application, I got toolbar type download. (please see the attached).

Regards,
Ganga S
0
Cody
Telerik team
answered on 16 Jul 2014, 09:05 PM
Hello,

I recognize you're dealing with trying to download a PDF file. Can you try this test which also downloads a PDF from a different website.

[TestMethod]
public void PDFDownloadFileTest()
{
    Manager.LaunchNewBrowser(BrowserType.InternetExplorer);
    ActiveBrowser.NavigateTo("http://palefaceranch.org/");
 
    DownloadDialogsHandler DownloadHandler = new DownloadDialogsHandler(Manager.Current.ActiveBrowser, DialogButton.SAVE, "F:\\approvalrequest.pdf", Manager.Current.Desktop);
    Manager.DialogMonitor.Start();
 
    HtmlAnchor a = Find.ByAttributes<HtmlAnchor>("title=PRAI ACC Request for Construction Approval Form");
    a.Click();
 
    DownloadHandler.WaitUntilHandled(40000);
    Manager.Current.DialogMonitor.Stop();
}

If this works reliably it means the problem is specific to your application. We'll need a way of getting access to your application so we can see problem. Sometimes we can use a Fiddler trace to simulate your website to reproduce problems.

Regards,
Cody
Telerik
 
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
 
0
Ganga
Top achievements
Rank 1
answered on 20 Jul 2014, 11:06 PM
Hi Cody,

I am really appreciate your support for us to debugging the issue.

It is working all the time with “Unexpected dialog encountered. Taking no action.” error, but my app does not work all the time.

I can’t provide any information, due to our company security policy…

In addition, failed to download, if a machine is “Locked” (Public or our web site).

Regards,
Ganga S
0
Cody
Telerik team
answered on 21 Jul 2014, 01:34 PM
Hi Ganga,

We can safely ignore "Unexpected dialog encountered. Taking no action.".

It is expected for the test to fail on a locked machine. There are a few work arounds, all of them a bit cumbersome to use. Basically the problem is that access to the keyboard and mouse (which is required to handle the dialog) is blocked by Windows when the machine is in a locked state. There is no "fixing" this.

I can’t provide any information, due to our company security policy…

That is very unfortunate. Until I can reproduce your problem on my machine, there is nothing more I can do to help you. If it helps we're willing to sign a non-disclosure agreement.

Regards,
Cody
Telerik
 
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
 
0
Ganga
Top achievements
Rank 1
answered on 21 Jul 2014, 09:06 PM
Hi Cody,

I am very satisfied with your support….

I can simply accomplished file download issue with this workaround. It is working for me all the time without any failures in our CI environment.

public static void InvokeDownload(Element element)
{
       // Create the filename, save to Log folder for current run, file name to be
       // DateTime.Now.Ticks plus original file extension which will be added automatically
       //string fileName = String.Format("Download_{0}{1}{2}", DateTime.Now.Hour, DateTime.Now.Minute, DateTime.Now.Second);
       string fileName = String.Format("File_{0}{1}{2}", DateTime.Now.Hour, DateTime.Now.Minute, DateTime.Now.Second);
       string logPath = Manager.Current.Settings.LogLocation;
       string filePath = System.IO.Path.Combine(logPath, fileName);
 
       HtmlControl control = element.As<HtmlControl>();
             
        //Create dialogs
        DownloadDialogsHandler dlgHandler = new DownloadDialogsHandler(Manager.Current.ActiveBrowser, DialogButton.SAVE, fileName, Manager.Current.Desktop);
                                     
        try
        {
               //Clicking on button/link ‘Save Dialog’ will open    
                control.Click();
 
                //Wait until dialog is handled
               //dlgHandler.WaitUntilHandled(18000000); // It is not working for our application......I can able to run my test 100% of the time, If                 commented this line
                               
              // Search file path for file starting with fileName to find physical fileName
              string[] files = System.IO.Directory.GetFiles(logPath);
              foreach (string file in files)
              {
                    if (System.IO.Path.GetFileName(file).StartsWith(fileName, StringComparison.OrdinalIgnoreCase))
                    {
                        fileName = file;
                        break;
                    }
              }
              // Log to manager
              Manager.Current.Log.WriteLine(String.Format("File \"{0}\" downloaded.", fileName));
        }
        catch
        {
               //Manager.Current.ActiveBrowser.Window.SetFocus();
                WriteLog(element, "handling dialog");
         }
         finally{}         
}
 
Regards,
Ganga S
0
Cody
Telerik team
answered on 22 Jul 2014, 01:29 PM
Hi Ganga,

Excellent! I'm glad you found a working solution.

Regards,
Cody
Telerik
 
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
 
Tags
General Discussions
Asked by
Satyajeet
Top achievements
Rank 1
Answers by
Satyajeet
Top achievements
Rank 1
Nitin
Top achievements
Rank 1
Anthony
Telerik team
Amos
Top achievements
Rank 1
N1t1nA
Top achievements
Rank 1
Aliluyko
Top achievements
Rank 1
Cody
Telerik team
Mario
Telerik team
Raj
Top achievements
Rank 1
Ganga
Top achievements
Rank 1
Share this question
or