Tuesday, January 26, 2016

WebList Methods in QTP/UFT:

Exist
Description: Exist method is used to check whether an object is present in the application or not.
Syntax: ObjList.Exist
Return Type: A Boolean Value
Example1: Dim Var
Var = Browser(“Browser”).Page(“Page”).WebList(“WebLink”).Exist
Example2: Dim ObjList
Set ObjList = Description.Create
ObjLink(“MicClass”). Value = “WebList”
ObjLink(“Text”).Value = “TestList”
Var = Browser(“Name:=Browser”).Page(“Title:=Page”).WebList(ObjList).Exist
Msgbox var                                     ‘Display True / False
---------------------------------------------------------
Click
Description: Click method is used to click on the weblist present in the application.
Syntax: ObjList.Click
Return Type: None
Example1:  Browser(“Browser”).Page(“Page”).WebList(“ObjList”).Click
Example2: Dim ObjList
Set ObjList = Description.Create
ObjList (“MicClass”). Value = “WebList”
Browser(“Name:=Browser”).Page(“Title:=Page”).WebList(ObjList).Click
----------------------------------------------------------------------------------------------
GetROProperty
Description: GetROProperty method is used to get the current property value of an object at run time.
Syntax: ObjList.GetROProperty(“Property_Name”)
Return Type: Variant Value
Example1: Dim Var_Name
Var_Name = Browser(“Browser”).Page(“Page”).Weblist(“ObjList”).GetROProperty(“InnerText”)
Msgbox Var_Name
Var_Name = Browser(“Browser”).Page(“Page”).Weblist(“ObjList”).GetROProperty(“Items Count”)
Msgbox Var_Name
Var_Name = Browser(“Browser”).Page(“Page”).Weblist(“ObjList”).GetROProperty(“Selected item index”)
Msgbox Var_Name
Var_Name = Browser(“Browser”).Page(“Page”).Weblist(“ObjList”).GetROProperty(“Selected Items Count”)
Msgbox Var_Name
Var_Name = Browser(“Browser”).Page(“Page”).Weblist(“ObjList”).GetROProperty(“Selection”)
Msgbox Var_Name
Var_Name = Browser(“Browser”).Page(“Page”).Weblist(“ObjList”).GetROProperty(“visible”)
Msgbox Var_Name
Var_Name = Browser(“Browser”).Page(“Page”).Weblist(“ObjList”).GetROProperty(“Value”)
Msgbox Var_Name
Example2: Dim ObjList, Var_Name
Set ObjLink = Description.Create
ObjList (“MicClass”). Value = “WebList”
Var_Name = Browser(“Name:=Browser”).Page(“Title:=Page”).WebLink(ObjList).GetROProperty(“InnerText”)
Msgbox Var_Name    
----------------------------------------------------------------------------------------------
Select
Description: Select method is used to select item from the weblist.
Syntax: ObjList.Select(“Item”)
Return Type: None
Example1: Browser(“Browser”).Page(“Page”).WebList(“WebList”).Select (“Item”)
Example2: Dim ObjList
Set ObjList = Description.Create
ObjLink(“MicClass”). Value = “WebList”
Browser(“Name:=Browser”).Page(“Title:=Page”).WebList(ObjList).Select(“Item”)
-----------------------------------------------------------------------
Deselect
Description: Deselect method is used to deselect item from the weblist.
Syntax: ObjList.Deselect(“Item”)
Return Type: None
Example1: Browser(“Browser”).Page(“Page”).WebList(“WebList”).Deselect (“Item”)
Example2: Dim ObjList
Set ObjList = Description.Create
ObjLink(“MicClass”). Value = “WebList”
Browser(“Name:=Browser”).Page(“Title:=Page”).WebList(ObjList).Deselect(“Item”)
---------------------------------------------------------------------------------
GetItem
Description: GetItem method is used to get the item value based on the specified item index from the weblist.
Syntax: ObjList.GetItem(index_value)
Return Type: A variant value
Example1: Dim Var_Value
Var_Value = Browser(“Browser”).Page(“Page”).WebList(“WebList”).GetItem(2)
Example2: Dim ObjList, Var_Value
Set ObjList = Description.Create
ObjLink(“MicClass”). Value = “WebList”
Var_Value = Browser(“Name:=Browser”).Page(“Title:=Page”).WebList(ObjList).GetItem(2)
Msgbox Var_Value
----------------------------------------------------------------------------
CaptureBitmap
Description: CaptureBitmap method is used to capture a screen of the object present in the application.
Syntax: ObjList.CaptureBitmap(“FilePath”)
Return Type: None
Example1:  Browser(“Browser”).Page(“Page”).Link(“ObjList”).CaptureBitmap(“C:\FileName.png”)
Example2: Dim ObjList
Set ObjList = Description.Create
ObjList (“MicClass”). Value = “WebList
ObjList (“InnerText”).Value = “TestList”

Browser(“Name:=Browser”).Page(“Title:=Page”).WebList(ObjList).CaptureBitmap(“C:\Name.bmp”)

DataTable Methods and Properties in QTP/UFT:

AddSheet
Description: AddSheet method is used to add specified sheet to the run time datatable.
Syntax: DataTable.AddSheet(“Sheet_Name”)
Return Type: DTSheet Object
Example: DataTable.AddSheet(“Sheet_Name”)
----------------------------------------------------------------------
DeleteSheet
Description: DeleteSheet method is used to delete the specified sheet from the run time datatable.
Syntax: DataTable.DeleteSheet(“Sheet_Name OR SheetID”)
Example: DataTable.DeleteSheet(“Sheet_Name”)
DataTable.DeleteSheet(“Sheet_ID”)                                                ‘SheetID can be sheet name or index.
------------------------------------------------------------------------
Import
Description: Import method is used to import the excel file to the run time datatable.
Syntax: DataTable.Import(“File_Path”)
Example: DataTable.Import(“File_Path”)
-----------------------------------------------------------------------
ImportSheet
Description: Importsheet method is used to import a sheet to a specified sheet in the run time datatable.
Syntax: DataTable.Import(“File_Path”, Source_Sheet, Destination_Sheet)
Example: DataTable.Import(“File_Path”, Source_Sheet, Destination_Sheet)
---------------------------------------------------------------------
Export
Description: Export method is used to create and save a copy of runtime data table.
Syntax: DataTable.Export(“File_Path”)
Example: DataTable.Export(“File_Path”)
-----------------------------------------------------------------------
ExportSheet
Description: Exportsheet method is used to export a specified sheet of the run time datatable.
Syntax: DataTable.ExportSheet(“File_Path”, Destination_Sheet)
Example: DataTable.ExportSheet(“File_Path”, Destination_Sheet)
--------------------------------------------------------------------------
SetCurrentRow
Description: SetCurrentRow method is used to Set the specified row as current row in the run time datatable.
Syntax: DataTable.SetCurrentRow(Row_Number)
Example: DataTable.SetCurrentRow(5)
-----------------------------------------------------------------------------
SetNextRow
Description: SetNextRow method is used to set the next row as current row after the current row in the run time datatable.
Syntax: DataTable.SetNextRow
Example: DataTable.SetNextRow
---------------------------------------------------------------------------
SetPreviousRow
Description: SetPreviousRow method is used to set the previous row as current row in the run time datatable.
Syntax: DataTable.SetPreviousRow
Example: DataTable.SetPreviousRow
---------------------------------------------------------------------------
GetCurrentRow
Description: GetCurrentRow method is used to get the current row in the first sheet in the run time datatable.
Syntax: DataTable.GetCurrentRow
Return Type: Number
Example: Dim Row_Num
Row_Num = DataTable.GetCurrentRow
-----------------------------------------------------------------------------
GetRowCount
Description: GetRowCount method is used to get the row count in the first sheet in the run time datatable.
Syntax: DataTable.GetRowCount
Return Type: Number
Example: Dim Row_Count
Row_Count = DataTable.GetRowCount
-------------------------------------------------------------------------------
GetSheet
Description: GetSheet method is used to get the specified sheet from the run time datatable.
Syntax: DataTable.GetSheet(“Sheet_Name OR Sheet_ID”)
Example: DataTable.GetSheet(“Sheet_Name OR Sheet_ID”)
---------------------------------------------------------------------------------
GetSheetCount
Description: GetSheetCount method is used to get the Sheet count in the run time datatable.
Syntax: DataTable.GetSheetCount
Return Type: Number
Example:  Dim Sheet_Count

Sheet_Count = DataTable.GetSheetCount

Monday, January 25, 2016

Link Methods in QTP/UFT:

Exist
Description: Exist method is used to check whether an object is present in the application or not.
Syntax: ObjLink.Exist
Return Type: A Boolean Value
Example1: Dim Var
Var = Browser(“Browser”).Page(“Page”).Link(“Link”).Exist
Example2: Dim ObjLink
Set ObjLink = Description.Create
ObjLink(“MicClass”). Value = “Link”
ObjLink(“Text”).Value = “TestLink”
Var = Browser(“Name:=Browser”).Page(“Title:=Page”).Link(ObjLink).Exist
Msgbox var                                     ‘Display True / False
---------------------------------------------------------
Click
Description: Click method is used to click on the link present in the application.
Syntax: ObjLink.Click
Return Type: None
Example1:  Browser(“Browser”).Page(“Page”).Link(“Link”).Click
Example2: Dim ObjLink
Set ObjLink = Description.Create
ObjLink(“MicClass”). Value = “Link”
ObjLink(“Text”).Value = “TestLink”
Browser(“Name:=Browser”).Page(“Title:=Page”).Link(ObjLink).Click
----------------------------------------------------------------------------------------------
GetROProperty
Description: GetROProperty method is used to get the current value of an object at run time.
Syntax: ObjLink.GetROProperty(“Property_Name”)
Return Type: Variant Value
Example1: Dim Var_Name
Var_Name = Browser(“Browser”).Page(“Page”).Link(“Link”).GetROProperty(“Text”)
Example2: Dim ObjLink, Var_Name
Set ObjLink = Description.Create
ObjLink(“MicClass”). Value = “Link”
ObjLink(“Text”).Value = “TestLink”
Var_Name = Browser(“Name:=Browser”).Page(“Title:=Page”).Link(ObjLink).GetROProperty(“Text”)
Msgbox Var_Name    
----------------------------------------------------------------------------------------------
CaptureBitmap
Description: CaptureBitmap method is used to capture a screen of the object present in the application.
Syntax: ObjLink.CaptureBitmap(“FilePath”)
Return Type: None
Example1:  Browser(“Browser”).Page(“Page”).Link(“Link”).CaptureBitmap(“C:\FileName.png”)
Example2: Dim ObjLink
Set ObjLink = Description.Create
ObjLink(“MicClass”). Value = “Link”
ObjLink(“Text”).Value = “TestLink”

Browser(“Name:=Browser”).Page(“Title:=Page”).Link(ObjLink).CaptureBitmap(“C:\FileName.bmp”)