Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Passing Object to Function
#1
Solved: 6 Years, 3 Months, 4 Weeks ago
I need to pass an object to a function and wait until it no longer exists - as it is not saved until the popup has disappeared.
I need to set a time out for the popup displaying to stop looking after a certain time
This is required on many different panels / popup, so I want the same code to work just based on a same browser, different page, different heading on popup

I have tried the following but it does not reset the .exist line, so the value never changes to false
Code:
Function waitToBeSaved(strObject) – being Browser(BrowserName).Page(PageName). object (popup header)

Dim strObject                           'to hold page object description
Dim intCounter                         'to store loop counter value
Dim strFinished                             'to store page existence value

intCounter = 0
strFinished = strObject.Exist
Do While  (intCounter <10) OR (strFinished = True)
             strFinished = strObject.Exist(1)
             intCounter = intCounter+1
Loop
If intCounter = 10 Then
      Reporter.ReportEvent micFail........
      Exit Test
End If
End Function

This works fine outside of the function
Do I need to Set the object??
Reply
#2
Solved: 6 Years, 3 Months, 4 Weeks ago Wink 
This solution is working - worked it out myself.

Code:
'Wait for save to finish

WaitForSave(Browser("PDCS").Page("A").WebElement("Popup"))

Function WaitForSave(theObj)
timeSpent = 0
waitTimeOut = 20
Set tempObj = theObj 'example: (Browser("PDCS").Page("A").WebElement("Popup"))
Do While tempObj.Exist(0)
  If timespent = waitTimeOut Then
   Reporter.ReportEvent micFail, "Wait for Save", "Waiting for save to finalise and has not completed in " & timeSpent & " seconds. Need to check why it has not saved. Test will stop"
         ExitTest
     Else
      Wait 1
    timeSpent = timeSpent + 1
  End If
Loop
End Function
Reply
#3
Solved: 6 Years, 3 Months, 4 Weeks ago
Just in case anyone is looking - this also works 
This is waiting for the object to appear and waits till it does, or drops out if it doesn't appear after a certain time

Function WaitForResult(theObj)
 timeSpent = 0
 waitTimeOut = 20
 Set tempObj = theObj 'example: Browser("PD").Page("SearchPage").WebTable("Results Table")
 Do While tempObj.Exist(0) = False
  If timespent = waitTimeOut Then
   Reporter.ReportEvent micFail, "Wait for Result", "Waiting for a result to occur and has not appeared in " & timeSpent & " seconds. Need to check why it has not saved. Test will stop"
         ExitTest
     Else
      Wait 1
    timeSpent = timeSpent + 1
  End If
 Loop
End Function
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Calling a Function in Function Library when function is defined in an Action jitenderkkr 0 2,971 11-27-2014, 12:53 PM
Last Post: jitenderkkr
  Passing objects to Functions vinod.nhce 0 3,300 03-13-2014, 06:09 PM
Last Post: vinod.nhce
  How to make a function for an object that has a large number of parent objects Shroomsday 1 2,399 01-28-2014, 11:15 PM
Last Post: jacosta
  How can I fetch server time using function Now or any other function? blanchedsouza 2 5,109 11-07-2009, 08:34 PM
Last Post: Ankur
  Passing the object list as the argument arun2kindia 1 2,307 07-28-2009, 03:01 PM
Last Post: manabh

Forum Jump:


Users browsing this thread: 2 Guest(s)