Sunday, February 7, 2010

Invoke the Browser using QTP , Load the URL, Close the browser and Delete the cookies

systemUtil.Run "Iexplore.exe","www.naukri.com"
'Check wether Qtp Invoked the application or not
qa= Browser( "Cannot find server").GetROProperty("OpenedByTestingTool")
'find the HWND ID
qa1= Browser( "Cannot find server").GetROProperty("hwnd")
'Find the Name of the browser
qa2= Browser( "Cannot find server").GetROProperty("name")
'Find title of the Browser
qa3= Browser( "Cannot find server").GetROProperty("title")
'Close the browser
Browser("Cannot find server").close
SystemUtil.CloseDescendentProcesses
SystemUtil.CloseProcessByHwnd qa1
SystemUtil.CloseProcessByName "qa2"
SystemUtil.CloseProcessByWndTitle "qa3"


'Chk the Address Bar, true or flase
Msgbox Browser("Cannot find server").Object.AddressBar
'Application Name
Msgbox Browser("Cannot find server").Object.Application
'check Browser is busy
Msgbox Browser("Cannot find server").Object.Busy
'Check is a Object or not
Msgbox Browser("Cannot find server").Object.Document
'Name of the Browser and Path
Msgbox Browser("Cannot find server").Object.FullName
'Browser is Full scrreen or Not
Msgbox Browser("Cannot find server").Object.FullScreen
'Height of the Browser
Msgbox Browser("Cannot find server").Object.Height
'Find the HWND ID
Msgbox Browser("Cannot find server").Object.HWND
'Chk the Left
Msgbox Browser("Cannot find server").Object.Left
'Application name
Msgbox Browser("Cannot find server").Object.LocationName
'check Memu Bar is visiable
Msgbox Browser("Cannot find server").Object.MenuBar
'Name of the application
Msgbox Browser("Cannot find server").Object.Name
'check application is Off mode
Msgbox Browser("Cannot find server").Object.Offline
'check the Parent of the application
Msgbox Browser("Cannot find server").Object.Parent
'Path of the application
Msgbox Browser("Cannot find server").Object.Path
'Wether apps is Ready state
Msgbox Browser("Cannot find server").Object.ReadyState
'chk the size of the apps
Msgbox Browser("Cannot find server").Object.Resizable
'chk Object doing any action
Msgbox Browser("Cannot find server").Object.Silent
'check the status Bar
Msgbox Browser("Cannot find server").Object.StatusBar
'display the Status bar Text
Msgbox Browser("Cannot find server").Object.StatusText
'Chk the Full Screen Mode
Msgbox Browser("Cannot find server").Object.TheaterMode
'chk the Tool Bar
Msgbox Browser("Cannot find server").Object.ToolBar
'Type of the Application
Msgbox Browser("Cannot find server").Object.Type
'check the Visiblity of the Browser
Msgbox Browser("Cannot find server").Object.Visible
'Width of the Browser
Msgbox Browser("Cannot find server").Object.Width
'Close the browser
Browser("Cannot find server").close
SystemUtil.CloseDescendentProcesses
SystemUtil.CloseProcessByHwnd qa1
SystemUtil.CloseProcessByName "qa2"
SystemUtil.CloseProcessByWndTitle "qa3"

Built-in Environment Variable for QTP

MyVar = environment("ActionIteration")
Msgbox MyVar
MyVar = environment("ActionName")
Msgbox MyVar
'MyVar = environment("ControllerHostName")
'Msgbox MyVar
'MyVar = environment("LocalhostName")
'Msgbox MyVar
MyVar = environment("OS")
Msgbox MyVar
'MyVar = environment("OsVersion")
'Msgbox MyVar
MyVar = environment("ProductDir")
Msgbox MyVar
MyVar = environment("ProductName")
Msgbox MyVar
MyVar = environment("ProductVer")
Msgbox MyVar
MyVar = environment("ResulrDir")
Msgbox MyVar
'MyVar = environment("Scenairold")
'Msgbox MyVar
MyVar = environment("SystemTempDir")
Msgbox MyVar
MyVar = environment("TestDir")
Msgbox MyVar
MyVar = environment("TestIteration")
Msgbox MyVar
MyVar = environment("TestName")
Msgbox MyVar
MyVar = environment("UserName")
Msgbox MyVar
'MyVar = environment("UpdatingAcvtiveScreen")
'Msgbox MyVar
'MyVar = environment("UpdatingtoDescriptions")
'Msgbox MyVar
'MyVar = Environment("Vuserid")
'Msgbox MyVar

Monday, February 1, 2010

Add Space Or Remove space on Variable

Remove the Space from the Variable

Dim MyValue,MyFunction,MyReturn
MyValue = "Vinodh Kumar"
MyFunction = split(MyValue, " " , -1,1)
MyReturn =MyFunction(0)& space(0) & MyFunction(1)
msgbox MyReturn

Add some Space from the Variable

Dim MyString, MyArray, MyReturn
MyString = "MDVDebuggerXForXVinodh"
MyArray = Split(MyString, "X", -1, 1)
msgbox myarray(0)
MyReturn = MyArray(0) & " " & MyArray(1)
MyReturn = MyReturn & " " & MyArray(2)
MsgBox MyReturn

QTP - Excel Part1

Write a program to Import an excel file to a Data table

datatable.Import("C:\vbsample.xls")

Write a program to Read data from first parameter of Global sheet

a = Datatable.Value("UserName",Global)
Dialog("text:=Login").WinEdit("attached text:=Agent Name:").Set a

Run all the Rows in Global sheet or Local Sheet using mercury Login Apps

datatable.Import("C:\vbsample.xls")
DataTable.ImportSheet "C:\vbsample.xls",1,1
c = datatable.GetCurrentRow
d = datatable.GetRowCount

For i = c to d -1 step 1
systemUtil.Run("C:\Program Files\Mercury Interactive\QuickTest Professional\samples\flight\app\flight4a.exe")

a = Datatable.Value("UserName",Global)
Dialog("text:=Login").WinEdit("attached text:=Agent Name:").Set a

b = Datatable.Value("Password",global)

Dialog("text:=Login").WinEdit("attached text:=Password:").Set b
Dialog("text:=Login").Winbutton("text:=OK").click
window("Flight Reservation").Close
datatable.SetNextRow
Next

Write a program to Read data from all sheets and all parameters of the excel file

Set ExlApp = CreateObject("Excel.Application")
Set ExlB = ExlApp.Workbooks.open("C:\vbsample.xls")
Set Exlbs = ExlApp.worksheets(1)
colcount = Exlbs.usedrange.columns.count
Rowcount =Exlbs.usedrange.rows.count
'Msgbox colcount
'Msgbox rowcount
For i =2 to rowcount -1 'step 1
colval = exlbs.cells(i,1)
systemUtil.Run("C:\Program Files\Mercury Interactive\QuickTest Professional\samples\flight\app\flight4a.exe")
Dialog("text:=Login").WinEdit("attached text:=Agent Name:").Set colval
For j=2 to colcount -1 'step 1
rowval =exlbs.cells(2,j)
'msgbox rowval
Dialog("text:=Login").WinEdit("attached text:=Password:").Set rowval
Dialog("text:=Login").Winbutton("text:=OK").click
window("Flight Reservation").Close
Next
'If (colcount = rowcount)Then
' For j=2 to colcount -1 step 1
' rowval = exlbs.cells(j,1)
' msgbox rowval
'Next
'End If
'Datatable.SetNextRow
Next
set ExlAppl=nothing
Set Exlb = nothing
Set Exlbs= nothing