Thread Rating:
  • 4 Vote(s) - 3 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How can i write a script in QTP to poll a folder for a new file?
#1
Solved: 11 Years, 3 Months, 3 Weeks ago
Hello

can anyone help me with one of the below things?

1. Can i be able to check a folder from QTP for any newfile with a given name?

2. Or can i be able to check the Websphere MQ record from QTP.

Basically I am running a testcase which calls a webservice to run but there is no direct response from Webservice it creates a record in the WS Que and creates and XML file in a specific folder . Is there any way i can check for one of this to make sure that my test is passed.

Thanks allot for the help.

-G
Reply
#2
Solved: 11 Years, 3 Months, 3 Weeks ago
Hi,

The answer for you first question is Yes. We can verify whether a folder or a file exists using fso object

FolderExists Method:
Code:
Returns True if a specified folder exists; False if it does not.
   Dim fso, msg, fldr
   fldr = "C:\Windows"  
   Set fso = CreateObject("Scripting.FileSystemObject")
   If (fso.FolderExists(fldr)) Then
      msg = fldr & " exists."
   Else
      msg = fldr & " doesn't exist."
   End If

FileExists Method:-
Code:
Returns True if a specified file exists; False if it does not.
The following example illustrates the use of the FileExists method.
   Dim fso, msg, filespec
   filespec = "C:\boot.ini"
   Set fso = CreateObject("Scripting.FileSystemObject")
   If (fso.FileExists(filespec)) Then
      msg = filespec & " exists."
   Else
      msg = filespec & " doesn't exist."
   End If


-Mr.K
Reply
#3
Solved: 11 Years, 3 Months, 3 Weeks ago
Thanks allot Mr.K,

Thats working fine.. Can I be able to check the folders on the server instead of C:\ , do i need to link anywhere that server??
Reply
#4
Solved: 11 Years, 3 Months, 3 Weeks ago
Yes, You can by giving the server ip address or computer name

Code:
Dim fso, msg, filespec
filespec = "\\192.168.1.1\c$\boot.ini"
Set fso = CreateObject("Scripting.FileSystemObject")
If (fso.FileExists(filespec)) Then
msgbox filespec & " exists."
Else
msgbox filespec & " doesn't exist."
End If


Let me know if this works

-Mr.K
Reply
#5
Solved: 11 Years, 3 Months, 3 Weeks ago
Thanks .K

its working fine...u rock..
Reply
#6
Solved: 11 Years, 3 Months, 3 Weeks ago
Another thing which you would want to do here is to keep on checking the folder or file exist since you mentioned polling...this code would check once...but you need to develop a logic to check the availability for some time.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Creating a folder from within a reusable action. sd3 2 3,177 06-18-2013, 03:20 PM
Last Post: learnQtptips
  How to write In PDF Form using QTP anukapoor 3 5,500 04-05-2012, 06:00 PM
Last Post: atulparate
  QTP file compare - ignoring file structure Fede 3 5,275 02-17-2012, 02:48 AM
Last Post: Parke
  Is this possbile to write the script without using the Object in object repository? njnirmal 4 8,547 01-03-2012, 05:29 PM
Last Post: shivu.hanu
Shy Help about write color text by QTP in Excel mantis 1 5,360 12-29-2011, 10:46 AM
Last Post: sshukla12

Forum Jump:


Users browsing this thread: 1 Guest(s)