Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Failed to run test due to unknown error: Need help!
#1
Solved: 11 Years, 4 Months ago
Hi,

I have written the following function to calculate the loading time.
Objective: Open Google Page
Click on any link (say, Maps)
Calculate time required for the Google Maps page to load

Code:
Public Function CheckLoadTime(ByVal LnkName,ByVal BroName,ByVal PagName)
'Dim LnkName
'Dim BroName
'Dim PagName
Browser("Bro_Google").Page("Pag_Google").Sync
Browser("Bro_Google").Page("Pag_Google").Link(LnkName).Click
StartTime=MercuryTimers.Timer("Timer1").Start
Browser(BroName).Page(PagName).Sync
StopTime=MercuryTimers.Timer("Timer2").Stop
CheckLoadTime=StopTime-StartTime
End Function

Call CheckLoadTime("Lnk_Maps","Bro_GoogleMaps","Pag_GoogleMaps")
msgbox CheckLoadTime(LnkName,BroName,PagName)

Now, when I run the test, GoogleMaps opens, but I get a error as
"Failed to run test due to uknown error" and it points to Line(6):
Code:
Browser("Bro_Google").Page("Pag_Google").Link(LnkName).Click

Can someone please tell me where I am going wrong?I know,perhaps my basics are not in place, but I am learning.

Thanks,
Joshi
Reply
#2
Solved: 11 Years, 4 Months ago
I guess you are passing name of link to the Lnkname as parameter to the function. So you should use DP here to identify the link you need to click

try this
Code:
Browser("Bro_Google").Page("Pag_Google").Link("name:=" & LnkName).Click

Reply
#3
Solved: 11 Years, 4 Months ago
Hi Saket,

I tried your suggestion, but there is still an issue.
The code is now:
Code:
Public Function CheckLoadTime(ByVal LnkName,ByVal BroName,ByVal PagTitle)
Browser("Bro_Google").Page("Pag_Google").Sync
Browser("Bro_Google").Page("Pag_Google").Link("name:="&LnkName).Click
wait(2)
StartTime=MercuryTimers.Timer("Timer1").Start
Browser("name:=" & BroName).Page("title:=" & PagTitle).Sync
StopTime=MercuryTimers.Timer("Timer2").Stop
CheckLoadTime=StopTime-StartTime
End Function
Call CheckLoadTime("Maps","Google Maps","Google Maps")
msgbox CheckLoadTime(LnkName,BroName,PagTitle)

What is happening is:
Maps link is clicked..qtp quickly runs through the next steps, even the last step and then, i see that it stops at Step6 again which is
Code:
Browser("Bro_Google").Page("Pag_Google").Link("name:="&LnkName).Click
It stops here cos it doesnt find "Link maps", obviously it wont cos it has already opened it.
Why doesnt it stop at msgbox and just get the output?
I dont get this behavior.
Either you/someone please help me!
Reply
#4
Solved: 11 Years, 4 Months ago
I guess you are trying to get the page load time with this function. right?
But what I am not able to understand here is why do you need to call the same function twice in your script.
Code:
Call CheckLoadTime("Maps","Google Maps","Google Maps")
msgbox CheckLoadTime(LnkName,BroName,PagTitle)

you can just get your output with a single statement only
Code:
msgbox CheckLoadTime("Maps","Google Maps","Google Maps")

I just tried with your code and it works fine with a single statement. let me know if there is any issue
Suggestion: use Services.StartTransaction and Services.EndTransaction to get the page load time
see if this helps you.

Reply
#5
Solved: 11 Years, 4 Months ago
Why not use like this,

Code:
Public Function CheckLoadTime(ByVal LnkName,ByVal BroName,ByVal PagName)
'Dim LnkName
'Dim BroName
'Dim PagName
Browser("Bro_Google").Page("Pag_Google").Sync
Browser("Bro_Google").Page("Pag_Google").Link(LnkName).Click
StartTime=Timer
Browser(BroName).Page(PagName).Sync
StopTime = Timer
CheckLoadTime=StopTime-StartTime
End Function
Basanth
Give a fish to a man and you feed him for a day..Teach a man how to fish and you feed him for life.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  How to send/pass UFT Run Error Dialog as output value to main driver script lravi4u 0 583 11-05-2023, 03:55 PM
Last Post: lravi4u
  Send automatic email notification when test run started helmzshelmz 0 1,068 04-03-2020, 07:54 AM
Last Post: helmzshelmz
  OpenNewTab stopped working on IE after unknown windows update M851533 0 1,103 07-19-2018, 08:36 AM
Last Post: M851533
  How to identify an error page occurring in server in between the qtp run. aswini 1 1,782 05-04-2017, 03:52 PM
Last Post: Ankur
  Test runned from QualityCenter generated an error "Attempted to divide by zero." robertosalemi 1 2,566 10-14-2016, 08:38 PM
Last Post: robertosalemi

Forum Jump:


Users browsing this thread: 3 Guest(s)