2017-06-05 195 views
1

我需要使用UFT将excel下载并保存到特定的位置。如何使用UFT下载和保存excel文件?

步骤1:如下面所见

enter image description here

步骤2单击超链接:保存下载的Excel,如下所示。 enter image description here

您可以请教如何使用uft自动化这种情况?

+0

你为什么要点击它?为什么你不能右击链接并使用另存目标? –

回答

0

据我所知,UFT的网络支持不能处理这种情况。这可能是UFT的基于图像的自动化(aka Insight)可以使用的情况。

如果UFT无法将其识别为原生WinButton s,则可以使用Insight识别所需的按钮。

0

我必须应用我自己的解决方法来管理从此设置保存文件。下面是我使用的代码:

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 

我必须学会的通知栏进入或作为WinObject,而SaveDropdown对象附加到上月底的向下箭头。我还必须使用.SetSelection.Type方法,而不是正常的.Set,因为SaveAs对话框最终会将文件保存为最初指定的文件而不是所需的路径和文件名。

您可以忽略LOG_Write语句,因为它们是我用来跟踪脚本进度的自定义函数。