Awesum Stuff

How to save file at desired location using QTP

While scripting for web application, one always faces an issue in selecting a folder location to save the file. Suppose, script clicks on download button on the page to download a file) and then presented with the Save as dialog box (shown below) that shows after clicking on the Save button.

Image

Now, to save file to desired location (suppose Desktop), Desktop icon on the left side of the dialog box needs to be clicked.

To do this, we only need to type or set the full path of the desired location along with the file name in the File Name field in the Dialog Box and then click on Save button

To save the file in Downloads folder on Desktop, just set “C:\Users\<username>\Desktop\Downloads\file.txt” in the File Name field and click on Save button

Advertisements

18 replies »

  1. Im having performance issues with this procedure causing the “Save as” pop-up not to respond and stopping the entire script. Can this process be bypassed?

  2. Mikkel – can you please elaborate – If save as pop up is non-responding, then it is itself an issue with the application that needs to be fixed?

  3. the application is a SAP environment from where I need to save a document. This often leads to the “Save As” window (fetched from Words) crashes. It could be either Words or SAP causing this.

  4. There are few things that you can try:

    1) Without launching QTP, can you try to save the word file manually and check if it is getting saved properly without any issues. If the document is getting saved without the dialog becoming non-responding, then there can be issue with QTP interfering with SAP application. You have to contact HP for that and follow Step2 for workaround

    2) If it is non-responding also when you try to save the file without launching QTP, then instead of clicking Save button using the button object of QTP, you can try to click the same button by sending keyword keys (using sendkeys/devicereplay method etc)

  5. Hi,
    This happens with file dialog boxes, etc. The problem is that SAP does not re-gain focus until the pop-up is closed, which means it tells QTP it is still waiting for the previous step (clicking the link, in your case) to finish. Therefore QTP cannot go on to the next step. As I recall, you need to change the recording method (to standard windows, or maybe low-level) before you click the link. This will probably add a Window object, and whatever the child link obect would be, to the OR. After closing the pop-up, you can go back to normal SAP recording.
    Regards,
    Kathirvel Nagaraj

  6. Hi,

    I tried above method, but file is not storing in desired location. My code is

    strFileName = FilePath&”\”&TCName&”_”&month(date)&”_”&day(date)&”_”&year(date)&”_”&replace(Time(),”:”,””)
    this will give me strFileName = C:\Users\Shri\Desktop\Output\Download_10_28_2015_64714 PM.xls

    If WpfWindow(“abc”).Dialog(“Export To Microsoft Excel”).Exist(5) Then
    WpfWindow(“abc”).Dialog(“Export To Microsoft Excel”).WinEdit(“File name:”).Set strFileName
    WpfWindow(“abc”).Dialog(“Export To Microsoft Excel”).WinButton(“Save”).Click

    if I do manually with above path the file is saving in desired location.

  7. Can you apply breakpoint on the following statement and then check value for strFileName from debug window:

    WpfWindow(“abc”).Dialog(“Export To Microsoft Excel”).WinEdit(“File name:”).Set strFileName

    Check if strFileName is same as below:
    C:\Users\Shri\Desktop\Output\Download_10_28_2015_64714 PM.xls

  8. i get below results on breakpoint
    WpfWindow(“abc”).Dialog(“Export To Microsoft Excel”).WinEdit(“File name:”).Set strFileName
    Default file name: xyz12345

    WpfWindow(“abc”).Dialog(“Export To Microsoft Excel”).WinButton(“Save”).Click
    C:\Users\Shri\Desktop\Output\Download_10_28_2015_64714 PM.xls

  9. Please try both ways and check if it solves the issue:

    1) Please run the code till the below statement:

    WpfWindow(“abc”).Dialog(“Export To Microsoft Excel”).WinEdit(“File name:”).Set strFileName
    and then click on Save button manually to check if the file is getting saved to the correct location.

    2) Please change the strFileName to C:\Download_10_28_2015_64714 PM.xls and check if solves the issue.

  10. Whatever folder is open by default. file saves in that location.

    1. Not saved in desired location on manual
    2. Same

    File save in default open folder. please advise

  11. Can you try below statement to set the path in WinEdit:

    WpfWindow(“abc”).Dialog(“Export To Microsoft Excel”).WinEdit(“File name:”).Type strFileName
    wait(5)

    Also, can you provide your mail id so that we can work on this issue effectively?

  12. Thank you for your response.

    It worked with Type 🙂

    WpfWindow(“abc”).Dialog(“Export To Microsoft Excel”).WinEdit(“File name:”).Type strFileName

  13. I need to save a file that’s downloaded from the web.
    Browse to the page
    Find the Excel Icon, click on it
    Now at the bottom of the page, a message “Do you want to open or save Search Results.xls from the site” Open, Save, Cancel.

    UFT is not recognizing this dialog. can you please help.

    Thanks
    Nandu

  14. Thanks Vijay. I also faced same issue and from last 2 days onwards searching for the soluntion. with Type method it’s working fine.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s