Difference between “Object not found” and “Object not ready” errors

Difference between “Object not found” and “Object not ready” errors

Object synchronization functions such as waitForObject or waitForObjectItem may return various error messages. Fully understanding these messages is important to debug a test script.

Squish recognizes GUI objects by a subset of their properties and values. In the example below, we would like to click on an object of type QToolButton with text “New”.

clickButton(waitForObject("{text='New' type='QToolButton'}"))

waitForObject/waitForObjectItem looks for an object with given properties and values. Additionally, it requires the object to be accessible (existing, enabled, visible). Those additional requirements are imposed because waitForObject/waitForObjectItem is used when we want to interact with GUI object (for example click an object or type to an object). When Squish finds at least one object matching the above condition, waitForObject/waitForObjectItem returns a reference to it.

Error Messages

1. First, Squish tries to find objects with given type. If it fails, the following error is raised:

LookupError: Object <name> not found. Could not match properties:
    type for object name: <name> 

2. When Squish finds one or more objects of the specified type, it tries to match the rest of properties. If one or more of the property value specified does not match any of the found objects, it gives an error:

LookupError: Object <name> not found. Could not match properties:
    <property> for object name: <name> 

3. When Squish finds an object with matching properties, then it checks if the object is accessible (existing, enabled, visible). If not, the following error is raised:

LookupError: Object <name> not ready. 

When all the above checks are performed then waitForObject/waitForObjectItem returns an object reference. Also, the above error messages are clear, so a user can find a cause of an error.

Special case

There is one case when Squish raises “Object not ready” error which needs more explanation. Let us assume that we have the following two buttons in our application:

Button1 with text “New”, currently hidden
Button2 with text “New”, currently visible

At the first glance, we would expect that the following code will click on the button with text “New” that is currently visible on the screen (Button2).

clickButton(waitForObject("{text='New' type='QToolButton'}"))

In fact, it may happen that “Object not ready” error is raised. The reason is that Button1 is found first (all properties are matching). For this button, accessibility check is performed which fails. How to avoid this situation? Just add a visible property:

clickButton(waitForObject("{text='New' type='QToolButton' visible='1'}"))
Tomasz started the adventure with Squish and GUI Testing in 2011. In 2014 he joined froglogic and is conducting Squish trainings and consulting for many companies in Europe, India and the USA.

0 Comments

Leave a reply

Your email address will not be published. Required fields are marked *

*