How to Skip the Specific row in arun time Datatable
Systemutil.Run "C:\Program Files\HP\QuickTest Professional\samples\flight\app\flight4a.exe"
Dialog("Login").Activate
If DataTable.GetCurrentRow=3 Then
Dialog("Login").WinButton("Cancel").Click
ExitTestIteration
else
Dialog("Login").WinEdit("Agent Name:").Set DataTable.Value("usr")
wait 3
Dialog("Login").WinEdit("Password:").Set DataTable.Value("pwd")
Dialog("Login").WinButton("OK").Click
Window("Flight Reservation").Close
End If
Dtatatable sheet:
usr pwd
venkat mercury
ram mercury
krishna mercury
nagaraju mercury
narsing mercury
pick the specific row data from datatable and enter into the script at runtime
Systemutil.Run "C:\Program Files\HP\QuickTest Professional\samples\flight\app\flight4a.exe"
y=Datatable.GetCurrentRow
x=3
If x=y Then
Dialog("Login").Activate
Dialog("Login").WinEdit("Agent Name:").Set Datatable.Value("username")
Dialog("Login").WinEdit("Password:").Set Datatable.Value("password")
Dialog("Login").WinButton("OK").Click
Window("Flight Reservation").Close
else
Dialog("Login").WinButton("Cancel").Click
End If
Dtatatable sheet:
usr pwd
venkat mercury
ram mercury
krishna mercury
nagaraju mercury
narsing mercury
Dim a
a=array(16,17,18,23,29,37,49,53,59)
For i=0 to ubound(a)
' x=a(i)
DataTable.GlobalSheet.AddParameter " ",a(i)
Next
'How to copy the data contents of global sheet to local sheet
For i=1 to 2
For j=1 to 2
c=DataTable.Value(i,j)
msgbox c
DataTable.GetSheet(2).SetCurrentRow(i)
DataTable.GetSheet(2).AddParameter "A",c
d=DataTable.Value(i,j)
msgbox d
Next
Next
'How to add the values in runtime for a specific sheet
For i=1 to 2
a=inputbox("enter a number")
DataTable.Value(1,i)=a
Next
GetRow with Cell Text Method:
Returns the number of the first row found that contains a cell with the specified text
Syntax:Object.GetRowWithCellText(Text,[Column],[StartfromRow])
row= Browser("xxx").Page("yyy").WebTable("zzz").GetRowWithCellText(Text, 2,2)
Set Link = Browser("xxx").Page("yyy").WebTable("zzz").ChildItem(row, 2, "Link", 0)
Link.Click
DataTable Methods:
Add Sheet:
Using these method we can add the new sheet to the run time data table
Syntax:Datatable.AddSheet "Sheetname"
Ex:Datatable.Addsheet "Venkat"
Delete Sheet:
Using these method we can delete the specified sheet from run time datatable
Syntax:Datatable.DeleteSheet "Sheetname"
Ex:Datatable.DeleteSheet "Venkat"
Export:
Saves a copy of the run-time Data Table in the specified location
Syntax:Datatable.Export(filename)
Ex:Datatable.Export("C:\Venkat.xls")
ExportSheet
Exports a specified sheet of the run-time Data Table to the
specified file.
If the specified file does not exist, a new file is created and the
specified sheet is saved.
If the current file exists, but the file does not contain a sheet with the
specified sheet name, the sheet is inserted as the last sheet of the
file.
If the current file exists and the file contains the specified sheet, the
exported sheet overwrites the existing sheet.
Syntax:
DataTable.ExportSheet(FileName, DTSheet)
DataTable.ExportSheet "C:\name.xls" ,1
GetCurrentRow
Returns the current (active) row in the first sheet in the run-time Data Table
(global sheet)
Syntax: Datatable.GetCurrentRow
Ex:MyParam=DataTable.GetSheet ("MySheet").AddParameter("Time", "8:00") Syntax: Datatable.GetCurrentRow
Ex: row = DataTable.GetCurrentRow
Reporter.ReportEvent 1, "Row Number", row
GetRowCount
Returns the total number of rows in the longest column in the first sheet in the
run-time Data Table (global sheet).
Syntax:Datatable.GetRowCount
Ex:
The following example uses the GetRowCount method to find the total number of
rows in the longest column of the MySheet run-time data sheet and writes it to
the report.
rowcount = DataTable.GetSheet("dtGlobalSheet").GetRowCount
Reporter.ReportEvent 2, "There are " &rowcount, "rows in
the data sheet."
The example below performs the equivalent of renaming a
column (parameter) in the DataTable by copying the data from one column to a new
column with a new name, and then deleting the old column.
'add a new
column
DataTable.GetSheet("dtGlobalSheet").AddParameter "NewColumn","Row1Value"
'copy the cells from the old column into the new column
cnt=DataTable.GetRowCount
For i=1 to cnt
DataTable.SetCurrentRow(i)
OldVal=DataTable.Value("OldColumn","dtGlobalSheet")
DataTable.Value("NewColumn","dtGlobalSheet")=OldVal
Next
'delete the old column
DataTable.GetSheet("dtGlobalSheet").DeleteParameter("OldColumn")
DataTable.GetSheet("dtGlobalSheet").AddParameter "NewColumn","Row1Value"
'copy the cells from the old column into the new column
cnt=DataTable.GetRowCount
For i=1 to cnt
DataTable.SetCurrentRow(i)
OldVal=DataTable.Value("OldColumn","dtGlobalSheet")
DataTable.Value("NewColumn","dtGlobalSheet")=OldVal
Next
'delete the old column
DataTable.GetSheet("dtGlobalSheet").DeleteParameter("OldColumn")
GetSheet:
Returns the specified sheet from the run-time Data Table
Syntax:DataTable.GetSheet(SheetID)
GetSheetCount:
Returns the total number of sheets in the run-time Data Table
Syntax:Datatable.GetSheetCount
Ex:
sheetcount = DataTable.GetSheetCount
Reporter.ReportEvent 0, "Sheet number", "There are " &
sheetcount & " sheets in the Data Table."
SetPrevRow
Sets the row above the current (active) row as the new current (active) row in the run-time Data
table
Synatax: Datatable.SetPrveRow
Ex:Datatable.SetPrveRow
SetNextRow
Sets the row after the current (active) row as the new current row in the run-time Data Table
Syntax:
DataTable.SetNextRow
Ex:
DataTable.SetNextRow
SetCurrentRow:
Sets the specified row as the current (active) row in the run-time Data Table
Syntax:Datatable.SetCurrentRow
Ex:Datatable.SetCurrentRow
No comments:
Post a Comment