Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
how to save a .pdf file in a browser window in qtp
#7
Solved: 11 Years, 3 Months, 3 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


Messages In This Thread
RE: how to save a .pdf file in a browser window in qtp - by Ankesh - 09-13-2012, 03:05 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Object doesn't support this property or method: 'window(...).window(...).winobject' senthil5683 1 3,674 07-04-2016, 07:08 PM
Last Post: venkatesh9032
  How to update CSV File and need to Save same CSV File kotaramamohana 1 3,513 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,459 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,460 03-11-2014, 12:13 PM
Last Post: devarapallliramana
Rolleyes QTP 11 not identify PDF Browser laxminaranaya 1 2,390 02-25-2014, 01:34 PM
Last Post: guin.anirban

Forum Jump:


Users browsing this thread: 8 Guest(s)