javainstancerft

Count the total instances of the same test object. RFT:Java


I am getting this error

"exception_name = com.rational.test.ft.AmbiguousRecognitionException exception_message = CRFCN0527E: Found 90 instances of the same test object. This often happens when multiple instances of the application are running."

This is expected and wanted. Right now to deal with this I have a try catch. The problem is it takes like 10 seconds for this to get thrown. It is taking this long because it is going through all 90 instances of the same test object.

My question is how can I either speed this up or throw the test after more than one instance is found?

Example to show what I mean

try{
    if(SomeObject().totalInstancesCount() == 1){
       SomeObject().click();
    }
}catch(Exception e){

}

Solution

  • As far as I know RFT will try to find all the objects to give you either the best match or throw AmbigiousRecognitionException .
    You can give a try to the find() API as well that will give you the number of matching candidates based on the find string you have passed and you can use the 0-based index to refer to the one you want. But with both the approaches I think in case of multiple matches time taken would still be the same i.e the time it takes to go through all the objects.