-
Junior Member
How to run the Bath file using QTP/Vbscript
Hi,
Please let me know how to run the Batch file using Vbscript/QTP script aswell as how to close the command prompt?
Regards,
Pradeep
-
Expert Member
Re: How to run the Bath file using QTP/Vbscript
Hi i can do like this for batch testing..........
I have taken 3 tests as a example for doing batch run. They are
1 is display - It will display a message in a word doc.
2 is displaydate - It will display a date and time as a message box.
3 is multiplication- It will display the mathematical table in a Notepad.
I converted them into respective functions and saved in notepad as a vbs file.(in C:\VB LIBRARY FILES\)
And I wrote a VBS function that is called above 3 functions. and saved as a callAll.vbs( in C:\VB LIBRARY FILES\)
Before running this test(BatchTestRun) I loaded all the files into resource tab
callAll()'Here i am just calling callAll function which is defined in callAll.vbs File.
*************************
display.vbs:
public function display()
'To open a word doc,type something and save the doc and close
set WordObj = CreateObject("Word.Application")
WordObj.visible = true
Set WordDoc = WordObj.Documents.Add
WordDoc.Range.InsertBefore "Hi Good Morning!"
WordDoc.SaveAs "C:\Greetings.doc"
WordObj.quit
Set WordObj = nothing
end function
**************************
displaydate.vbs:
public function displaydate()
'To display the date in Notepad
set fso=createobject("scripting.filesystemobject")
set fptr=fso.createtextfile("c:\sample.txt")
a=FormatDateTime(Date, 1)
msgbox a
fptr.writeline a
end function
****************************
multiplication.vbs:
public function multiplication()
'To open notepad and write a mathematical table in that throug QTP and save in C Drive and close
Set obj=createobject("Scripting.filesystemobject")
Set of=obj.createtextfile("c:\mat.txt")
For i=1 to 10
x=5*i
of.writeline"5 * "&i&" = "&x
Next
end function
*****************************
CallAll.vbs:
public function callAll()
display()
msgbox "Test 1 is Pass"
displaydate()
msgbox "Test 2 is Pass"
multiplication()
msgbox "Test 3 is Pass"
end function
*******************************
'''''''''''''''Like this we can run multiple tests at a time without using TestBatchRunner Application...
'''''''''''''''By putting a flag at end of the each function, we can know that status of the particular test is executed or not.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules