Quantcast
Channel:
Viewing all articles
Browse latest Browse all 43798

Wiki Page: Handling a com.borland.silktest.jtf.common.InvalidObjectHandleException in Silk4J

$
0
0
Created On:  04 May 2012   The following Knowledge Base article, 31679 , details one way in which the said exception can be handled in Silk4J. Should the solution detailed in the article above not fit with your current automation framework then the following method can be used to verify whether a locator generates a stable handle over a given period of time:       public static boolean wait4ValidHandle(Desktop _desktop, String sLocator, int iValidMatchCount, int iMaxAttempts, int iInterval ){           TestObject handle = null ;           boolean diffHandle = true ;           FindOptions fo = new FindOptions( false , 250);           int iFound = 0;           int iAttempts = 0;           boolean bValidHandle = false ;           while ( true ){                //if the handle is null or no longer valid refind the control                if (handle == null || true ){                     handle = _desktop.find(sLocator,fo);                     diffHandle = false ;                }                if (handle!= null ){                     if (handle.exists()){                          iFound++;                     }                     else {                          iFound = 0;                          diffHandle = true ;                     }                }                //if the same handle has been found iValidMatchCount times                if (iFound == iValidMatchCount){                     //break the while loop                     bValidHandle = true ;                     break ;                }                //if we have reached the maximum attempts break the loop                if (iAttempts == iMaxAttempts){                     break ;                }                //sleep for the interval                try {                     Thread. sleep (iInterval);                }                catch (Exception e){                     e.printStackTrace();                }                iAttempts++;           }           return bValidHandle;      } Where:      - _desktop : is the Desktop object passed from your test method to the above helper method      - sLocator : is the locator for the control that a stable handle must be found      - iValidMatchCount : is the amount of times we must successfully find the same handle      - iMaxAttempts : is the maximum amount of times we can try to find a stable handle      - iInterval : is the time in milliseconds that we wait before verifying if the handle is still valid The said function can then be used in the following context with your test method:      if (Utilities. wait4ValidHandle ( desktop , "//TextField" , 10, 60, 250)){           desktop .find( "//TextField" ).setText( "Found a valid handle" );      } Old KB# 35930

Viewing all articles
Browse latest Browse all 43798


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>