Ask a Question

aqFile* Exists not find application-created folder

SOLVED
thebick
Occasional Contributor

aqFile* Exists not find application-created folder

My application creates a folder during execution, but TestComplete's aqFile* methods don't find it during the test.

Not aqFile.Exists, not aqFileSystem.Exists, not aqFileSystem.FindFolders. (But they do find the already-existing parent)

If I leave the folder in place and run a second test, it finds the folder.

If I call CreateFolder() during the test, FindFolders() finds only that folder, not the one my app created.

I'm running on a Windows 10 VM on Windows 10. The folder is on the host, shared with the VM.

The test is written in Python.

How can I get TestComplete to find the folder that my application creates during the test?

 

Correction: The folder is on the VM, not shared from the host

5 REPLIES 5
Wamboo
Community Hero

Hi thebick,

 

Can you share with us a code example?

Perhaps cache side-effect.

It happens on my W10 sometimes, not in TC but simply in Explorer. Need to make a F5 to make it appears.

 

Use parent refresh method before checking folder.

 

Or use direct Windows API, https://docs.microsoft.com/en-us/windows/win32/api/shlwapi/nf-shlwapi-pathfileexistsa

 

 

Un sourire et ça repart

thebick
Occasional Contributor

# Portion of test script written in Python
# FormToCreateDirectory has already been properly assigned
# This function works and creates the directory
FormToCreateDirectory.OKButton.ClickButton()
parentDir= "D:\\parentDir"
if not aqFileSystem.Exists(parentDir):
   Log.Error("Can't find " + parentDir)
# If I don't have this line, foundFolders is None
aqFileSystem.CreateFolder(parentDir + "\\" + "bogusFolder")
foundFolders = aqFileSystem.FindFolders(parentDir)
if foundFolders != None:
    Log.Error("No folders in " + parentDir)
while foundFolders.hasNext():
   aFolder = foundFolders.Next()
   Log.Message("found folder " + aFolder)

The only Folder found is bogusFolder

thebick
Occasional Contributor

Not sure I understand what you mean.

When the application creates the folder (and a lot of sub-folders), I can see it easily in File Explorer -- just not via TC.

I do not have access to source code, so I can't change how it behaves.

 

Or are you suggesting something else?

tristaanogre
Esteemed Contributor


@thebick wrote:

Not sure I understand what you mean.

When the application creates the folder (and a lot of sub-folders), I can see it easily in File Explorer -- just not via TC.

I do not have access to source code, so I can't change how it behaves.

 

Or are you suggesting something else?


The suggestion is, as mentioned, system delay time.  Consider Button click happens and then the next lines of code execute almost immediately.  That might not be enough time to find the folder in the Windows file system (which is what aqFileSystem essentially is... a TC wrapper around around the FileSystem object from Microsoft).  So, perhaps a "delay" time of some sort... maybe a while loop to wait until either the folder exists OR you reach a maximum timeout.  Obviously, ParentDir exists by the time you get to creating bogus folder otherwise bogus folder wouldn't be found... so, there's a processing time there that needs to be accounted for.


Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available
cancel
Showing results for 
Search instead for 
Did you mean: