Hi All,
In this post, I am providing the couple of ways for closing all the active browsers .
Say there are '5' browsers which are opened.
Soultion 1 :
While Browser("CreationTime:=0").Exist
Browser("CreationTime:=0").Close
Wend
Solution 2:
systemutil.CloseProcessByName "iexplore.exe"
Output :
All 5 browsers will be closed......
Have a nice day folks.............
Key Objective of this QTP blog is to help real time Automation testers as well as who are at Beginner Level, Intermediate Level in QTP by providing plenty of Script/code Based examples,a lot of innovative things in QTP which I developed,gathered. Anybody Have Query ? got stuck in or held up in the middle of Automation using QTP ? Just post your queries here & I will get back to u with an adeqaute solution for all your queries. I am catchable at sreekanth.chilam@gmail.com
Thursday, February 26, 2009
Get number of Files in a Folder
Hi All,
Use the following way for finding the number of files in a folder.
Code:
Set objFileSysOb = CreateObject("Scripting.FileSystemObject")
Set colFolderName = objFileSysOb.GetFolder("give entire folder path here")
Set vFiles =colFolderName.Files
Sno=0
For each i in vFiles
d=Split(i,"\")
FileName=d(ubound(d))
Sno=Sno+1
msgbox "File "&Sno&" : "&FileName
Next
msgbox "Number of files in Current Folder : "&vFiles.count
Output :
Use the following way for finding the number of files in a folder.
Code:
Set objFileSysOb = CreateObject("Scripting.FileSystemObject")
Set colFolderName = objFileSysOb.GetFolder("give entire folder path here")
Set vFiles =colFolderName.Files
Sno=0
For each i in vFiles
d=Split(i,"\")
FileName=d(ubound(d))
Sno=Sno+1
msgbox "File "&Sno&" : "&FileName
Next
msgbox "Number of files in Current Folder : "&vFiles.count
Output :
Wednesday, February 25, 2009
Find the Links Count in a Web Page
Hi All,
'*********************************************
'*********************************************
' Function Defination :
'*********************************************
Function objects_count_in_Page(Req_obj)
Dim obj
Set obj=Description.Create
obj("micclass").Value=Req_obj
Set x=Browser("Google").Page("Google").ChildObjects(obj)
Req_obj_count= x.count()
msgbox Req_obj&"s"&" in WebPage : "&Req_obj_count
End Function
'*********************************************
Function Declarations/Function Calls of above Function:
'*********************************************
Call objects_count_in_Page("Link")
Call objects_count_in_Page("WebButton") :
Call objects_count_in_Page("WebEdit")
Output will be :
Monday, February 23, 2009
Script for Mutlipication Tables
Hi All,
Here i am providing the way creating Multiplication Table in Notepad using QTP.
SystemUtil.Run "notepad"
Window("text:=Untitled - Notepad").Activate
For I=1 to 3
For I=1 to 3
For J = 1 to 10
x = I * J
Window("text:=Untitled - Notepad").Type I &"*"& J &"=" &x
Window("text:=Untitled - Notepad").Type micReturn
Next
Next
Output :
Sunday, February 22, 2009
Get Column Count,Col names of DataTable
HI All,
Here i am posting the ways of retreiving the column count & column names used in datasheets of datatable.
Implement the given ways accordingly........Have a Nice day.
'**************************************
To Retrieve the Column count Data Table :
'**************************************
Syntax :
Col_count= Datatable.GetSheet("SheetName").GetParameterCount
Example1:
Col_count= Datatable.GetSheet("Action1").GetParameterCount
msgbox "No. of columns used in "&Environment("ActionName")&" are : " &Col_count
'*****************************************
To Retrieve the Column Names of Data Table :
'*****************************************
Syntax :
Datatable.GetSheet("SheetName").GetParameter(Column Number).Name
Example1 :
Col_Name=Datatable.GetSheet("Action1").GetParameter(1).Name
msgbox " Column name is : "&Col_Name
Here i am posting the ways of retreiving the column count & column names used in datasheets of datatable.
Implement the given ways accordingly........Have a Nice day.
'**************************************
To Retrieve the Column count Data Table :
'**************************************
Syntax :
Col_count= Datatable.GetSheet("SheetName").GetParameterCount
Example1:
Col_count= Datatable.GetSheet("Action1").GetParameterCount
msgbox "No. of columns used in "&Environment("ActionName")&" are : " &Col_count
'*****************************************
To Retrieve the Column Names of Data Table :
'*****************************************
Syntax :
Datatable.GetSheet("SheetName").GetParameter(Column Number).Name
Example1 :
Col_Name=Datatable.GetSheet("Action1").GetParameter(1).Name
msgbox " Column name is : "&Col_Name
Create List Box in VB script
Hi All,
'USAGE of the above code:
JUST COPY PASTE BELLOW CODE IN QTP AND EXECUTE ....
Function Create_List_Dialog(Title, message, List)
On Error Resume Next
msg = message
for i = lbound(List) to ubound (List)
for i = lbound(List) to ubound (List)
newmess = msg & vbCrLf & cstr(i + 1) & " - " & List(i)
msg = newmess
next
flag = 0
flag = 0
do while flag = 0
Ret = InputBox(msg,Title,"1")
Ret = CInt(Ret)
Create_List_Dialog = List(Ret-1)
flag = 1
If Create_List_Dialog = "" Then
flag = 1
End if
Loop
End Function
'USAGE of the above code:
domains = Array("Yahoo Mail","G Mail","Rediff Mail","Hot Mail","Sify Mail","EXITFROMTEST")
OUTPUT = Create_List_Dialog("MAIL LOGIN", "SELECT APPLICATION", domains)
msgbox OUTPUT
'Find the Output of the above code:
Subscribe to:
Posts (Atom)