Forum Discussion

aldebaran's avatar
aldebaran
Occasional Contributor
13 years ago

Waiting for control

Hi all,



I sometimes get exceptions in script-routines when the real object behind a mapped object is passed as a parameter from a keyword test.

This only happens sometimes, because the object, in this case a .net DataGridView, is not completly finished loading with all it´s columns and rows. In the script it seems as if the projects "auto wait time" has no effect for a gridView´s Column or Row properties ?!



The exception message: Dieser Vorgang wurde wegen Zeitüberschreitung zurückgegeben
Unit: "SetVariables" Line: 8 Column: 6.

I guess in English it woud translate to: "The procedure was terminated due to a timeout Unit: ...."

The script-routine in question works perfect and is used from plenty of other keyword-tests.



Here´tis:

Sub setGridLastRowIndex( GridObj )

     Project.Variables.LastGridRowIndex = GridObj.Rows.Count -1

     Log.Message("LastGridRowIndex is: " & Project.Variables.LastGridRowIndex)

End Sub



auto wait time is high: 30000 milliseconds



I would like to avoid inserting any extra teststeps or calls to yet another script from the keyword tests that use 'setGridLastRowIndex'



What´s the dos and donts if one wants to avoid absolute waits?



Any suggestions are appreciated.



greets



c.

1 Reply

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor
    The best way to do this without using hardcoded "Delay" calls is to use a WaitProperty method on the object.  The Object may be loaded but, as you pointed out, the property is not fully resolved yet.  So something like



    MyObject.WaitProperty("RowCount", "10", 10000)




    Will wait for the RowCountProperty of MyObject to equal the number 10 for a maximum of 10 seconds.  If the property resolves before those 10 seconds, the method returns as TRUE.  If it takes longer than the 10 seconds, then the method returns as FALSE.  You can wrap an If/Then around that then to say "If not WaitProperty Then Log Error" or whatever you need to have happen.



    There is a whole set of topics in the help for this particular kind of scenario at http://smartbear.com/support/viewarticle/12558/



    For the WaitProperty method specifically, check out http://smartbear.com/support/viewarticle/12532/