Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Function written in Func library is not returning values but works in same script
#1
Not Solved
Hi,

Below function when put in a function library is not returning values, while the same copied to same script works.

Note:Script is associated with the library & other sub procedures in the same library called by the same script are working fine.

Below is the code in the script:
Code:
Set myxl=nothing
Set myxl=Createobject("Excel.Application")
myxl.Application.Visible=True
User="sfp"
'Create Link object
Set weblnk=nothing
Set weblnk=description.Create
weblnk("micclass").value="Link"
Set objAlllinkobj=Nothing
Set objAlllinkobj=Browser("title:=.*","micclass:=Browser").Page("title:=.*","micclass:=Page").ChildObjects(weblnk)

''Create excel file to write data
Environment.Value("Alllinksfile")= "C:\Linkcheck\" & User & ".xlsx"
filepath=Environment.Value("Alllinksfile")
Set fso=Createobject("Scripting.FileSystemObject")
If fso.FileExists(filepath) Then
    fso.DeleteFile filepath
End If

Set xlbok=myxl.Workbooks.Add
Set mysheet=nothing
Set mysheet=myxl.Worksheets("Sheet1")
mysheet.cells(1,1)="Link"
mysheet.cells(1,2)="Status"
mysheet.cells(1,3)="Error Code"
mysheet.cells(1,4)="URL"

For a=0 to objAlllinkobj.count-1
roc=mysheet.usedrange.rows.count

url = objAlllinkObj(a).getroproperty("href")
'msgbox url
nam=objAlllinkObj(a).getroproperty("name")

'URL status
Call Geturlstatus (url)
Next

*************************************
Function  Geturlstatus(url)
On Error Resume Next
     'Call ClearBrowserCache()
     Set objhttp = nothing
     Set objhttp= CreateObject("Microsoft.XMLHTTP")  ' Create an xmlhttp object
     objhttp.open "GET", url, False     ' Opens the connection to the remote server
     objhttp.Send
     pagestatus = objhttp.status
    

     If pagestatus >= "200" or pagestatus <= "206" Then
         mysheet.cells(roc+1,1)=nam
         mysheet.cells(roc+1,2)="Success"
         mysheet.cells(roc+1,3)=pagestatus
         mysheet.cells(roc+1,4)=url
                     'geturlstatus = 0

     elseif pagestatus >= "302" or pagestatus <= "307" Then
          mysheet.cells(roc+1,1)=nam
         mysheet.cells(roc+1,2)="Redirection"
         mysheet.cells(roc+1,3)=pagestatus
         mysheet.cells(roc+1,4)=url
             'geturlstatus = 0

      elseif pagestatus >= "400" or pagestatus <= "423" Then
         mysheet.cells(roc+1,1)=nam
         mysheet.cells(roc+1,2)="Client Error"
         mysheet.cells(roc+1,3)=pagestatus
         mysheet.cells(roc+1,4)=url
            'geturlstatus = 0

  elseif pagestatus >= "500" or pagestatus <= "505" Then
         mysheet.cells(roc+1,1)=nam
         mysheet.cells(roc+1,2)="Server Error"
         mysheet.cells(roc+1,3)=pagestatus
         mysheet.cells(roc+1,4)=url
               ' geturlstatus = 1
    
     End If
     Set objhttp = nothing
     End Function
**************************************************
Reply


Messages In This Thread
Function written in Func library is not returning values but works in same script - by Shwethareddy - 02-21-2013, 04:56 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
Question [HELP]Button no longer works in the transaction ME21N(SAP/QTP) rafaponzio 11 9,604 12-21-2022, 06:08 PM
Last Post: Carlos Veras
  Calling a Function in Function Library when function is defined in an Action jitenderkkr 0 2,781 11-27-2014, 12:53 PM
Last Post: jitenderkkr
  DP is not returning the whole table data content soumen 6 4,741 10-02-2013, 12:05 PM
Last Post: vvcyril
  Same code on running with UFT11.5 gets slow and browser hangs but works fine inQTP11 Rashi 1 2,417 03-02-2013, 04:12 PM
Last Post: vinod123
  Script running more times than the values in global data table TPavani 5 4,171 10-04-2012, 11:18 PM
Last Post: krr

Forum Jump:


Users browsing this thread: 1 Guest(s)