Hi,
I need help how to save PDF file using QTP. It is a web-based application.
The following are the steps i need to perform to get the PDF.
1. Select Data from WebList
2. Click Refersh
3. Application opens a PDF File in a browser itself
When i am try to capture SAVE button of PDF, it capture whole toolbar instead of only SAVE button.
When i record it, it says Browser().Page().Frame().WinObject().Click X,Y
Awaiting for the earliest replies.
Regards,
Shashavali
can you use shortcut keys on the page to save such as Ctrl+S??? If yes, try using sendkey/Type.
Regards,
Ankesh
Try using Virtual object concept....will work.
Thank you very much for ur replies...
@ Ankesh : - I tried using shortkeys "CTRL+S" , but it didn't worked.
@ freeboynil :- when i am trying to create Virtual Object, QTP throws an error "Failed to Create The Virtual Object Definition"
It will be helpful if you provide some detail about it.
@ssvali ,
It is alwys better to post the code which u hv tried, the error and the screenshot of the application.
Regards,
Ankesh
Here is the script and snapshot
Code:
Browser("").Page("").Frame("").Image("Refresh").highlight
Browser("").Page("").Frame("").Image("Refresh").Click
Browser("").Page("").Sync
Set WshShell = CreateObject("WScript.Shell")
Browser("").Page("").Frame("").highlight
WshShell.SendKeys "%s"
Can you see the address in you adress bar something like
www.google.com/File_Opened.pdf?
If yes, you can try the below code.
Code:
'Create an object
Set WinHttp = CreateObject("WinHttp.WinHttpRequest.5.1")
If WinHttp Is Nothing Then Set WinHttp = CreateObject("WinHttp.WinHttpRequest")
WinHttp.Open "GET", "http://google.com/your_pdf_file.pdf", False
WinHttp.Send
arrArray = WinHttp.ResponseBody
Set WinHttp = Nothing
On Error Resume Next
Set oADO = CreateObject("ADODB.Stream")
If oADO Is Nothing Then
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set oTextFile = oFSO.OpenTextFile("c:\Documnet_i_want_to_save.pdf", 2, True)
sData = ""
sBuffer = ""
For iCount = 0 to UBound(arrArray)
oTextFile.Write Chr(255 And Ascb(Midb(arrArray,iCount + 1, 1)))
Next
oTextFile.Close
Else
oADO.Type = 1
oADO.Open
oADO.Write arrArray
oADO.SaveToFile "c:\Documnet_i_want_to_save.pdf", 2 'File on your local
oADO.Close
End If
Set oADO = Nothing
Set oTextFile = Nothing
Set oFSO = Nothing
Makes sure the proxy is disabled on your system.
Let me know if this helps.
Regards,
Ankesh
Thanks ankesh for the reply.
I can see the address but not in the below mention format.
It shows only "http://www.google.com/"
Not a problem.
just update the line this WinHttp.Open "GET", "http://google.com/your_pdf_file.pdf", False
with the address which you can see. Try this once.
WinHttp.Open "GET", "http://google.com", False
let me know the output.
Hi Ankesh,
Thanks again for the quick response. I changed script as per ur suggestion. File is saved to local drive but if i open it throws an error.
Attached is the screenshot of Error.
Regards,
ssvali