Prepare for your Next Interview
This is a discussion on How to run the Bath file using QTP/Vbscript within the QTP forums, part of the Software Testing category; 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...
|
|||
|
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 |
| Sponsored Links |
|
|||
|
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. |
![]() |
|
| Thread Tools | |
| Display Modes | |
|
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| VBscript tutorial 4 QTP | QuickTestMichael | QTP | 1 | 07-24-2008 04:40 PM |
| How to write the vbscript in web based applications in qtp? | srinu.tenali | QTP | 2 | 12-20-2007 02:59 AM |
| How do I 'unpack' and view a .FILE vsam file | Geek_Guest | MainFrame | 0 | 06-26-2007 08:22 PM |
| Frigate3 File Manager: highly configurable and convenient file management environment | JobHelper | Geeks Lounge | 0 | 03-30-2007 02:30 PM |
| Regarding the convrsion of Vbscript files into .exe form | naveen.kamisetty | QTP | 0 | 03-28-2007 06:35 AM |