等待对象属性设置为挤压

时间:2018-02-13 12:05:46

标签: python pyqt squish

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

2 个答案:

答案 0 :(得分:2)

此示例来自Example - Testing or waiting for an expected property value

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));

答案 1 :(得分:0)

添加TimeoutMilliseconds无效,因此我添加了time.sleep(Seconds),这对我来说更好。