Friday, July 11, 2008

Edit/View the Same Object

1) For i=0 to 9
Browser("b1").Page("p1").WebEdit(name:="Text1","index:=" & i).Set Value
NextEnd Loop
2)Browser("Welcome: Mercury Tours").Page("Book a Flight: Mercury").WebEdit("text" & i).Set "name" & iNextHere objects need to be present in the OR
FOr the below one
For i=1 to 2Browser("Welcome: Mercury Tours").Page("Book a Flight: Mercury").WebEdit("text" & i).Set "name" & i Next

Declare the Array

1) Dim Variable1Array()Public varOne as Integer
Redim variable1Array(varone)
variable1Array(1) = "Sample1"variable1Array(2) = "Sample2"
2) Dim myarray(30)
myarray(0) = "raj"myarray(1) = "singh"

Load the .Vbs File

1) Executfile(" Path of file ")
2 ) Call Functionname(arg list)
3) Dim qtApp Dim qtLibraries
Set qtApp = CreateObject("QuickTest.Application")
Set qtLibraries = qtApp.Test.Settings.Resources.Libraries ' Get the libraries collection object
If qtLibraries.Find("C:sai1.vbs") = -1 Then ' If the library cannot be found in the collectionExecuteFile "C:sai1.vbs"
End If
Call test1()
Function In File Sai1.vbs Function test1()MsgBox "Hi Manish"End Function
4) sPath = "D:/Files/Functions.vbs"
Executfile (sPath)(OR) Executfile ("D:/Files/Functions.vbs")

Convert the Date Format like : 30-May-2004

Function date_ddmonyyyy(vDate)

' return the date in the DD-MON-YYYY format, ex. 31-Aug-2004

If vDate = "" Then

vDate = Date()

End If
a = MonthName(Month(CDate(vDate)), true) b = Day(Date()) c = Year(Date())
If b<10 b="0">

End If
date_ddmonyyyy = b & "-" & a & "-" & c

End Function

Remove the OR in to QTP

Public Function remove_obj_repository(Action_Name)

Dim qtAppDim qtRepositories

'As QuickTest.ObjectRepositories

' Declare an action's object repositories collection variable

Set qtApp = CreateObject("QuickTest.Application") ' Create the Application

objectSet qtRepositories = qtApp.Test.Actions(Action_Name).ObjectRepositories

' Get the object repositories collection object of the "Login" action
' Removes the Object Repository Associated with the given Actionqt

Repositories.RemoveAll
End Function

Load the OR In QTP

Public Function load_obj_repository(ObjRepPath,Action_Name)

Dim qtAppDim qtRepositories

'As QuickTest.ObjectRepositories

' Declare an action's object repositories collection variable

Set qtApp = CreateObject("QuickTest.Application")

' Create the Application

objectSet qtRepositories = qtApp.Test.Actions(Action_Name).ObjectRepositories

' Get the object repositories collection object of the "Login" action
' Add MainApp.tsr if it's not already in the collection

If qtRepositories.Find(ObjRepPath) = -1 Then ' If the repository cannot be found in the collection
qtRepositories.Add ObjRepPath, 1 ' Add the repository to the collection

End If

End Function

Close all Browser

Public Function close_all_browsers()
SystemUtil.CloseDescendentProcesses
On error resume next
End Function