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

squ 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.

错误消息

1.首先,啜饮试图找到具有给定类型的对象。如果失败,则提出以下错误:

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

2.当啜饮发现指定类型的一个或多个对象时,它会尝试匹配其余属性。如果指定的一个或多个属性值与任何找到的对象不匹配,则会给出错误:

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

3.当Quish查找具有匹配属性的对象时,它会检查对象是否可访问(现有,启用,可见)。如果没有,则提出以下错误:

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.

特例

当鳞片升起时有一种情况“Object not ready”需要更多解释的错误。让我们假设我们在我们的应用程序中有以下两个按钮:

Button1与文本“New”, currently hidden
button2与文本“New”, currently visible

在第一次浏览一眼,我们希望以下代码点击带文本的按钮“New”目前在屏幕上可见(Button2)。

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

事实上,可能会发生这种情况“Object not ready”出现错误。原因是首先找到Button1(所有属性匹配)。对于此按钮,执行可访问性检查失败。如何避免这种情况?只需添加一个可见的属性:

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

发表评论

您的电子邮件地址不会被公开。 必需的地方已做标记 *

复制链接