Re: Record file system using QTP (271 Views)
Reply
Advisor
qtp24
Posts: 37
Registered: ‎05-07-2014
Message 1 of 4 (338 Views)
Accepted Solution

Record file system using QTP

Hi,

 

I am trying to search a specific folder in D:\test directory using QTP. I did spy on the folders. It seems to me all the folders in a containter object. QTP does not recognize folders seperately. Any help?

 

-Q

Honored Contributor
Trudy Claspill
Posts: 3,717
Registered: ‎09-09-2010
Message 2 of 4 (318 Views)

Re: Record file system using QTP

What version of QTP are you using?

Are you using QTP to interact with a Windows Explorer dialog, or are you using vbscript code to interact with the file system?
[If this post solves or helps solve your issue, mark the thread as solved and give KUDOS to the author for their assistance.]

(Opinions expressed in my postings are mine alone, and do not reflect the opinions of my employer.No warranties express or implied for any solution/suggestion posted.)
Advisor
qtp24
Posts: 37
Registered: ‎05-07-2014
Message 3 of 4 (283 Views)

Re: Record file system using QTP

I am using qtp 11.

 

Not sure what to answer to your question.

 

Example: In C:\Test directory, folders are being created automatically from a VB application. Each time VB application creates a folder, I need to come to C directory to verify whether the folder was created.

 

Folders names will be test1, test2, test3, qtp1, qtp2, qtp3.

 

When a new folder gets created with prefix test, the next folder name will be test4. When a new folder gets created with prefix qtp, the fourth qtp folder name will be qtp4, so on.

 

I need QTP to find out whether the new folder has created with the same prefix in the given directory.

 

HP Expert
vzamoraz
Posts: 502
Registered: ‎04-12-2012
Message 4 of 4 (271 Views)

Re: Record file system using QTP

Hello,

 

    You can use filesystem to get that.

    

Set fso=createobject("Scripting.FileSystemObject")
'Folder  for  getting details  
Sourcefolder="C:\Test"  
Set get_folder=fso.GetFolder(Sourcefolder) 
'get the subfolders count in a folder
Set  get_subfolder=get_folder.SubFolders
For  each  folder  in get_subfolder
'compare folder name
If folder.name = "expected value" then
'process to do
end if 
Next
Set fso=nothing

Regards.

If you find that this or any post resolves your issue, mark it as an accepted solution.

 

The code provided above is free and is just a sample, you need to adapt it and maintain it according to your needs.

 

Also remember if you have a valid contract with HP feel free to visit our FT/QTP Support Customer Forums:

 

http://h30499.www3.hp.com/t5/Functional-Testing-QTP/ct-p/sws-Fun_Test

 

You can create an account with your HP credentials

 

 

 

The opinions expressed above are the personal opinions of the authors, not of HP. By using this site, you accept the Terms of Use and Rules of Participation.