1

我正在使用 Squish 6.3 Qt。我正在测试的应用程序包含一个QLabel内容动态变化的应用程序。是否可以等待标签设置为特定值?我不能使用waitForObject,因为该对象始终存在,只有它的文本值不断变化。

4

3 回答 3

3

此示例来自示例 - 测试或等待预期的属性值

def main():
    # Register squish_dir/examples/qt/addressbook
    # for this example code:
    startApplication("addressbook")

    # This will fail, unless you create a new
    # address book and add a single entry to it,
    # but it demonstrates how to use this
    # function:
    if not waitForPropertyValue("{type='QTableWidget' visible='1'}", "rowCount", 1, 20000):
        test.fail("Property did not have the expected value")
    else:
        test.passes("Property had the expected value")


def waitForPropertyValue(objectName, propertyName, expectedValue, timeoutInMilliseconds):
    """Waits for property value of an already existing object"""

    condition = "findObject(objectName)." + propertyName + " == expectedValue";
    return waitFor(condition, timeoutInMilliseconds));
于 2018-02-14T09:36:53.340 回答
0

添加 TimeoutMilliseconds 不起作用,所以我添加了time.sleep(Seconds),这对我来说效果更好。

于 2018-10-19T20:38:00.697 回答
0

来自frog.ca的回答,正确的条件实现是:

condition = "findObject('{}').".format(objectName) + propertyName + "==" + str(expectedValue);
于 2021-10-14T09:31:43.810 回答