简体   繁体   中英

How to download and save excel file using UFT?

I need to download and save excel to a specific location using UFT.

Step 1: Click on hyperlink as seen below

在此处输入图片说明

Step 2: Save the downloaded excel as shown below. 在此处输入图片说明

Can you please advice on how to automate this scenario using uft?

As far as I know UFT's web support can't handle such cases. This may be a case where UFT's image-based automation ( aka Insight ) can be used.

You can use Insight to identify the required buttons if UFT doesn't recognise them as native WinButton s.

I have had to apply a workaround of my own to manage the saving of files from this setup. Here's the code I used:

If Browser("AFBHome").WinObject("Notification").Exist(6) Then
    LOG_Write "Notification received - click Save dropdown to get file."
    Browser("AFBHome").WinObject("Notification").WinButton("SaveDropdown").Click micNoCoordinate,micNoCoordinate,micRightBtn
    Browser("AFBHome").WinObject("Notification").WinButton("SaveDropdown").Click
    Wait 0,500 ' Allow the dropdown to render
    Browser("AFBHome").WinObject("Notification").WinButton("SaveDropdown").Type "a"
    Dialog("Save As").Activate
    Wait 0,500
    LOG_Write "Getting file from AFB: " & Dialog("Save As").WinEdit("FileName").GetROProperty("text")
    Dialog("Save As").WinEdit("FileName").SetSelection 0,Len(Dialog("Save As").WinEdit("FileName").GetROProperty("text"))
    Dialog("Save As").WinEdit("FileName").Type sSaveLocation & sFilename
    LOG_Write "Attempting to save export file as " & sSaveLocation & sFilename 
    Dialog("Save As").WinButton("Save").Click
End If

I had to learn the Notification Bar into the OR as a WinObject, and the SaveDropdown object is attached to the down arrow on the end. I also had to use the .SetSelection and .Type methods rather than the normal .Set as the SaveAs dialog would end up saving the file to whatever was originally specified rather than the desired path and filename.

You can ignore the LOG_Write statements, as they are a custom function I use to track progress through my scripts.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM