pythonpyqtsquish

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.


Solution

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