IMPORTANT - Avoid "occurrence" property in object names

Last edited on

Overview

If Squish encounters an object that's "identical" to an existing object, it introduces the "occurrence" property to disambiguate them

Even if the objects in question have other properties which can be used to reliably distinguish between them, if Squish doesn't know about those properties its only resort is to add an occurrence property so that they can be uniquely identified.

Since occurrence properties are added and given sequence numbers that reflect the chronological execution of the test script they are potentially less reliable than the properties that Squish normally uses to identify AUT objects. For example, a second test case may access the same application objects as the first test case---but in a different order (such as clicking the second tab then the first tab rather than the other way around in a window with a tab control), and this could cause playback problems.

Use of occurrence might indicate memory leaks in the AUT

Having an occurrence property appear may indicate that the AUT has a memory leak. For example, a window with various GUI elements is hidden and not used further, with a new "identical" window being created the next time that window is required, so it might be worth mentioning to the AUT's developers. (And if this is indeed the cause of Squish creating an occurrence property and the developers fix the problem, it will make future Squish tests more reliable since the occurrence property won't be needed any more.)

How to improve object names that contain occurrence

Whenever one of your object names has an occurrence property, it is worth trying to get rid of the property to make tests that use the object more reliable. Launch the AUT from Squish IDE so it goes into "Spy" perspective, and use the Application Objects view's "pick" mode to pick the object and then look at the object's properties in the Properties view. If you can find a uniquely identifying property that is likely to be stable (i.e., to have the same value on every run and throughout the time you are interested in accessing the object), consider adding this property to the object's name in the Object Map, and then removing the occurrence property. Squish will then use those names for identifying the objects. Please see Article - Explicitly Naming Objects for more details.

It is also possible to customize the properties used by Squish to give names to objects. This helps you avoid the need to edit the object names after recording. For more details on that, please see Object Name Generation .

Occurrence in Squish editions

EditionFirst instance available asSecond instance available asFurther information
iOS{...}{"occurrence": "2" ...}{"occurrence": "0" ...} not supported (use {...})
Java{...}, {"occurrence": "0" ...}{"occurrence": "1" ...}
Qt{...}, {"occurrence": "0" ...}, {"occurrence": "1" ...}{"occurrence": "2" ...}
Web{...}, {"occurrence": "0" ...}, {"occurrence": "1" ...}{"occurrence": "2" ...}
Windows{...}, {"occurrence": "1" ...}{"occurrence": "2" ...}{"occurrence": "0" ...} does not find any objects, but yields no error