Saving PDF in particular folder from IE browser through UFT

2.7k views Asked by At

Could someone help me with logic, i am new to automation UFT.

My aim is to save PDF by changing the name and in specific folder.

  1. click on preview button in main window to preview PDF
  2. new browser will open with PDF, but there is no address bar with URL for new browser or menu bar to save PDF.
  3. close only new browser so that i can go back to main browser for diff PDF

I used below logic to save PDF, but it works for only one time, as PDF already saved on desktop. I got around 200 PDF in browser.

Browser("Login").Page("Select Letter").WebButton("Enter").Click

Browser("Login").Page("Select Letter").WebButton("Next").Click

Browser("Login").Page("Select Letter").WebButton("Preview").Click

Browser("Login").Page("Select Letter").Sync

Set WshShell = CreateObject("WScript.Shell")

Browser("Browser").WinObject("AVPageView").highlight

WshShell.SendKeys "+^s"

Browser("Browser").Dialog("Save a Copy").WinTreeView("WinTreeView").Select "Favorites;Desktop"

Browser("Browser").Dialog("Save a Copy").WinButton("Save").Click

Browser("Browser").CloseAllTabs

Thanks in Advance

Sush

1

There are 1 answers

0
Prageeth Saravanan On

Based on your comment, I would try something like this..

Dim strFolderPath, strFileName, strFullPathToSave
Dim strCurrentTime
' Add the folder path 
strFolderPath = "C:\A_Preffered_Folder\PDF"

' Generate FileName 
strCurrentTime = now
strFileName =  Replace(Replace(Replace(strCurrentTime, "/",""),":",""), " ", "_")
strFullPathToSave = strFolderPath + "\" + strFileName + ".PDF"

NOW is the keyword, which would give you the current date and time. I simply replaced the "/", Spaces & ":" to genrate a file name. Just record saving the file again, this time instead of browsing the file, just type the full path. Ex: C:\A_Preffered_Folder\PDF\132017_35655_PM.PDF But make sure that the folder exists first. Once you have the code add the above code after you press ctrl s and replace the hardcoded value with the variable where you the file name.