Checking existence of remote files and folders (Qt)

Last edited on

To check for the existence of files and folders on the computer where the AUT is running one can use the Qt API:

import os 
try:   
    import __builtin__
except:
    import builtins as __builtin__
    
def main():
    startApplication("addressbook")

    test.log("Exists: " + str(path_exists("C:\\")))
    test.log("Exists: " + str(path_exists("C:\\non_existing")))

    p = os.environ["SQUISH_PREFIX"] + "/ChangeLog.txt"
    test.log("Exists: " + str(path_exists(p)))
    test.log("Is file: " + str(is_file(p)))
    test.log("Is dir: " + str(is_dir(p)))
    return

def path_exists(path):
    return __builtin__.bool(QFile(path).exists())

def is_file(path):
    return not is_dir(path)

def is_dir(path):
    return __builtin__.bool(QFile(path + "/").exists())