Geeks Talk

Prepare for your Next Interview




How to run the Bath file using QTP/Vbscript

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...


Go Back   Geeks Talk > Software Testing > QTP

Register FAQ Members List Calendar Mark Forums Read
  #1 (permalink)  
Old 01-09-2008
Junior Member
 
Join Date: Dec 2007
Location: pune
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
pradeep.madishetti is on a distinguished road
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
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 01-09-2008
Contributing Member
 
Join Date: Sep 2007
Location: Hyderabad
Posts: 93
Thanks: 1
Thanked 14 Times in 13 Posts
rajaputra is on a distinguished road
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.
Reply With Quote
Reply

  Geeks Talk > Software Testing > QTP


Thread Tools
Display Modes


Similar Threads

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


All times are GMT -4. The time now is 12:11 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Copyright © 2008 GeekInterview.com. All Rights Reserved