Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Does QTP support writing runtime data to multiple sheets in excel
#1
Solved: 11 Years, 3 Months, 3 Weeks ago
Hi,

I am trying to write data to multiple sheets in excel, but isnt working with the below code. Please let me know for any corrections.
Updating Links on different pages of the webpage directly to excel.

'Admin Login

Code:
Browser("CCAMS | Login").Page("CCAMS | Login").WebEdit("UserName").Set "sfpuc.admin@jenesys.in"
Browser("CCAMS | Login").Page("CCAMS | Login").WebEdit("Password").Set "admin@jenesys"
Browser("CCAMS | Login").Page("CCAMS | Login").WebButton("Login").Click

Set alllinkob = Description.Create()
alllinkob("micclass").value ="Link"

Set objAlllinkObj =Browser("CCAMS | Login").Page("CCAMS | Home | 1.1.33").ChildObjects(alllinkob)

'Write to Excel  
Set myxl=createobject("Excel.Application")
myxl.Application.Workbooks.Open "C:\LinkCheckLogin.xlsx"
myxl.Application.Visible=True
Set mysheet=myxl.ActiveWorkbook.Worksheets("Home")


'Home Page-fetching Links info
For a=0 to objAlllinkObj.count-1

url = objAlllinkObj(a).getroproperty("url")
nam=objAlllinkObj(a).getroproperty("name")

call geturlstatus(url )

Next
'Site Search-Different webpage in the same applictaion

Browser("CCAMS | Login").Page("CCAMS | Home | 1.1.33").Link("Site Search").Click

myxl.Application.Visible=True
Set mysheet=myxl.ActiveWorkbook.Worksheets("SiteSearch")


Set lnk=description.Create
lnk("micclass").value="Link"

Set Sitelnk=Browser("CCAMS | Login").Page("CCAMS | Site Search |").ChildObjects(lnk)
For a=0 to Sitelnk.count-1

url = Sitelnk(a).getroproperty("url")
nam=Sitelnk(a).getroproperty("name")

call geturlstatus(url )

Next
'Link Check function

Public Function geturlstatus(url )
     On Error Resume Next
     Call ClearBrowserCache()
     Set webService = nothing
     Set webService= CreateObject("Microsoft.XMLHTTP")  ' Create an xmlhttp object
     webService.open "GET", url, False     ' Opens the connection to the remote server
     webService.Send
     pagestatus = webService.status
     If pagestatus >= 200 or pagestatus <= 206 Then
         mysheet.Cells(a+2,1)=nam
         mysheet.Cells(a+2,2)="Success"
         mysheet.Cells(a+2,3)=pagestatus
         mysheet.Cells(a+2,4)=url
                     geturlstatus = 0

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

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

  elseif pagestatus >= 500 or pagestatus <= 505 Then
         mysheet.Cells(a+2,1)=nam
         mysheet.Cells(a+2,2)="Server Error"
         mysheet.Cells(a+2,3)=pagestatus
         mysheet.Cells(a+2,4)=url
                geturlstatus = 1
    
     End If
     Set webService = nothing
     err.clear
End Function
Reply
#2
Solved: 11 Years, 3 Months, 3 Weeks ago
What is the error you are getting?
Reply
#3
Solved: 11 Years, 3 Months, 3 Weeks ago
Hi Ankesh,
Thanks for teh reply, was able to solve it by addding new sheet method to shift teh focus to next sheet.

Thanks
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  QTP/UFT - Storing Multiple Arrays In An Array Eitel13 0 1,794 07-17-2018, 04:37 PM
Last Post: Eitel13
  Search and import data from excel under some rules. nwpulele 2 2,905 02-19-2015, 04:10 AM
Last Post: supputuri
  How to populate data in weblist using excel vijifun 1 3,298 12-05-2013, 12:06 PM
Last Post: basanth27
  Does QTP supports to open same application multiple times!!!!! pkiran169 1 2,954 08-07-2013, 01:09 PM
Last Post: anil2u
  Filter multiple columns in excel kamalteja 0 3,782 07-08-2013, 02:28 AM
Last Post: kamalteja

Forum Jump:


Users browsing this thread: 2 Guest(s)