Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
how to save a .pdf file in a browser window in qtp
#1
Solved: 10 Years, 8 Months, 2 Weeks ago
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
Reply
#2
Solved: 10 Years, 8 Months, 2 Weeks ago
can you use shortcut keys on the page to save such as Ctrl+S??? If yes, try using sendkey/Type.

Regards,
Ankesh
Reply
#3
Solved: 10 Years, 8 Months, 2 Weeks ago
Try using Virtual object concept....will work.
Reply
#4
Solved: 10 Years, 8 Months, 2 Weeks ago
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.
Reply
#5
Solved: 10 Years, 8 Months, 2 Weeks ago
@ssvali ,

It is alwys better to post the code which u hv tried, the error and the screenshot of the application.

Regards,
Ankesh
Reply
#6
Solved: 10 Years, 8 Months, 2 Weeks ago
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"


Attached Files Image(s)
   
Reply
#7
Solved: 10 Years, 8 Months, 2 Weeks ago
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
Reply
#8
Solved: 10 Years, 8 Months, 2 Weeks ago
Thanks ankesh for the reply.

I can see the address but not in the below mention format.
It shows only "http://www.google.com/"
Reply
#9
Solved: 10 Years, 8 Months, 2 Weeks ago
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.
Reply
#10
Solved: 10 Years, 8 Months, 2 Weeks ago
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


Attached Files Image(s)
   
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Object doesn't support this property or method: 'window(...).window(...).winobject' senthil5683 1 3,485 07-04-2016, 07:08 PM
Last Post: venkatesh9032
  How to update CSV File and need to Save same CSV File kotaramamohana 1 3,313 10-24-2015, 08:40 AM
Last Post: tigerliew
  Not able to click the save button in Save As window while downloading from SAP kathirvelnagaraj 0 2,287 08-25-2015, 07:37 PM
Last Post: kathirvelnagaraj
  Cannot find the "[ WebEdit ]" object's parent "[ Browser ]" (class Browser). Verify t Divya Roopa 1 8,274 03-11-2014, 12:13 PM
Last Post: devarapallliramana
Rolleyes QTP 11 not identify PDF Browser laxminaranaya 1 2,220 02-25-2014, 01:34 PM
Last Post: guin.anirban

Forum Jump:


Users browsing this thread: 1 Guest(s)