Dynamically wait an object in an application


“Dynamically wait an object in an application”

It known to all that scripts written for web application suffers a lot
when it comes to Wait() or Syc().Wait() statement waits for 10 sec which is
not recommended and wait(1),wait(2)..wait(n) cannot add any value if script has
to cope with multiple rows of data.Lets take an example.

No or rows(in data sheet) to process =300
Function retrievetransno()
Wait(2)
End function
If above function is called in each iteration, image how much execution
time is wasted.

2*300=600 sec
600/60=10 min

10 mins execution time is wasted if we are going to use wait statement.
If wait() is used then it’s more pathetic:
10*300=3000 sec
3000/60=50 min

Following function could be used to overcome the above issue.It dynamically
waits and check the status of the object within the given time limit and
exits out if the object is not present within that time limit.
1*300=300 sec
300/60=5 mins

Lets start with:

'===================================================================================================
'Function:ObjectChecker
'Purpose: Lets you dynamically wait the presence of an object in an application
'Arguments: vObj,iCounter
'@vObj:Test object
'@iCounter:Maximum no of seconds (to wait)
'Author: Bibek Khatiwara
'Created on: 15th june 2011
'===================================================================================================
Function ObjectChecker (vObj,iCounter)

vObjStatus = False
Flag = 0
Do
Flag = Flag+1
If vObj.Exist(1) Then
Reporter.ReportEvent micDone ,"Wait time calc","Seacrh text box displayed in "&Flag&" second(s)"
vObjStatus = True
Else
If Flag = iCounter Then
Exit Do
End If
End If
Loop Until vObjStatus = True
ObjectChecker = vObjStatus

End Function

'Usage(sample):
Set oTxtbox=Browser("name:=google.*").Page("title:=google.*").WebEdit("name:=q")
ObjectChecker oTxtbox ,10
Set oTxtbox=Nothing
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: