Micro Focus QTP (UFT) Forums
Failed to run test due to unknown error: Need help! - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: UFT / QTP Beginners (https://www.learnqtp.com/forums/Forum-UFT-QTP-Beginners)
+--- Thread: Failed to run test due to unknown error: Need help! (/Thread-Failed-to-run-test-due-to-unknown-error-Need-help)



Failed to run test due to unknown error: Need help! - Renu0113 - 09-26-2009

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


RE: Failed to run test due to unknown error: Need help! - Saket - 09-26-2009

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



RE: Failed to run test due to unknown error: Need help! - Renu0113 - 09-29-2009

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!


RE: Failed to run test due to unknown error: Need help! - Saket - 09-29-2009

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.


RE: Failed to run test due to unknown error: Need help! - basanth27 - 09-29-2009

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