简体   繁体   中英

Wait for an object property to be set in squish

I am using Squish 6.3 Qt. The application i am testing contains a QLabel whose content changes dynamically. Is it possible to wait for the label to be set to a particular value? I can't use waitForObject as the object always exists and only its text value keeps changing.

This example is from 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));

添加 TimeoutMilliseconds 不起作用,所以我添加了 time.sleep time.sleep(Seconds)并且这对我更有效。

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

condition = "findObject('{}').".format(objectName) + propertyName + "==" + str(expectedValue);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM