A Table containing any kind of information in cells in combinations of rows and columns. Keywords for Web Table are: Rows Columns Cell Cell Data RowCount ColumnCount GetCellData Getting Web Table Column headers Purpose: To get the Column headers of a table so as to write these headers as Column Names to a excel sheet Script: DataTable.AddSheet "MySheet" Set oTable=Browser("Gmail: Email from Google").Page("Gmail - Inbox").WebTable(t") RC=oTable.RowCount CC=oTable.ColumnCount(1) Print "RC " & RC Print "CC " & CC For i=1 to CC ColName=oTable.GetCellData(1,i) Print "ColName "& ColName DataTable.GetSheet("MySheet").AddParameter ColName,"" Next Web Table RowCount & ColumnCount Purpose: To get the number of rows and number of columns of a table from a page Script: Set MyTable=Browser("Gmail: Email from Google").Page("Gmail - Inbox").WebTable("html tag:=TABLE","name:=t") RC=MyTable.RowCount CC=MyTable.ColumnCount(1) Print "RC " & RC Print "CC " & CC Getting Cell Data from a Web Table Purpose: To get the cell data of a table from a page Method used is GetCellData(Row#,Col#) Script: Set Text = Browser("").Page("").WebTable("").GetCellData(1, 1) MsgBox "text contains" & Text Example: Set oTable=Browser("").Page("").WebTable("") For i=1 to RC CC=oTable.ColumnCount(i) For j=1 to CC CData=oTable.GetCellData(i,j) Print "CData " & CData Next Next
Getting Cell Data From Web Tables and writing to an excel Purpose: To the required cell data from a web table and write these values to an excel sheet Script: For i=1 to RC Datatable.GetSheet("MySheet").SetCurrentRow(i) CC=oTable.ColumnCount(i) For j=1 to CC CData=oTable.GetCellData(i,j) DataTable.GetSheet("MySheet").GetParameter(j).value=CData Print "CData " & CData Next Next Working Gmail Web Table - Demo Set oTable=Browser("Gmail: Email from Google").Page("Gmail - Inbox").WebTable(t") RC=oTable.RowCount CC=oTable.ColumnCount(1) Print "RC " & RC Print "CC " & CC For i=1 to CC ColName=oTable.GetCellData(1,i) Print "ColName "& ColName DataTable.GetSheet("MySheet").AddParameter ColName,"" Next For i=1 to RC Datatable.GetSheet("MySheet").SetCurrentRow(i) CC=oTable.ColumnCount(i) For j=1 to CC CData=oTable.GetCellData(i,j) DataTable.GetSheet("MySheet").GetParameter(j).value=CData Print "CData " & CData Next Next Reading an excel sheet and passing cell data as a link PCMySheet=DataTable.GetSheet("MySheet").GetParameterCount RCMySheet=DataTable.GetSheet("MySheet").GetRowCount For j=1 to RCMySheet For i=1 to PCMySheet CValue=DataTable.GetSheet("MySheet").GetParameter(i).ValueByRow(j) 'RCValue=DataTable.GetSheet("MySheet").GetParameter(3).ValueByRow(j) Print "CValue "& CValue Next Next For j=1 to RCMySheet 'For i=1 to PCMySheet 'CValue=DataTable.GetSheet("MySheet").GetParameter(i).ValueByRow(j) RCValue=DataTable.GetSheet("MySheet").GetParameter(3).ValueByRow(j) Print "RCValue "& RCValue 'Next Next To get the no# of web tables existing on page Purpose: To get the number of web tables existing on a page To the get all web tables names, text, rowcount, columncount Script: Set ObjTable=Description.Create ObjTable("html tag").value="TABLE" ObjTable("text").value=".*" Set TotObjTable=Browser("Gmail: Email from Google").Page("Gmail - Inbox").ChildObjects(ObjTable) NoOfTables=TotObjTable.count Print "NoOfTables " & NoOfTables For i=0 to NoOfTables-1 TabName=TotObjTable(i).GetROProperty("name") TabCols=TotObjTable(i).GetROProperty("cols") TabRows=TotObjTable(i).GetROProperty("rows") TabText=TotObjTable(i).GetROProperty("text") Print "TabName "& TabName Print "TabCols "& TabCols Print "TabRows "& TabRows Print "TabText "& TabText Next Working on a particular Web Table Purpose: Getting all the information from a known table (like RowCount, ColumnCount, CellData and so on) Why this script is for: This script helps to work on particular table to get all the info of that table so as to write data into an excel or passing particular cell data as parameter to the running test script or Verifying the table data if it is as per the requirements. Script: Set MyTable=Browser("Gmail: Email from Google").Page("Gmail - Inbox").WebTable("html tag:=TABLE","name:=t") RC=MyTable.RowCount CC=MyTable.ColumnCount(1) Print "RC " & RC Print "CC " & CC RC=Browser("Gmail: Email from Google").Page("Gmail - Inbox").WebTable("html tag:=TABLE","name:=t").RowCount CC=Browser("Gmail: Email from Google").Page("Gmail - Inbox").WebTable("html tag:=TABLE","name:=t").ColumnCount(1) Print "RC " & RC Print "CC " & CC DataTable.AddSheet "WebTable" For i=1 to CC CName=MyTable.GetCellData(1,i) DataTable.GetSheet("WebTable").AddParameter CName,"" Next For i=1 to RC CC=MyTable.ColumnCount(i) For j=1 to CC MyData=MyTable.GetCellData(i,j) Print "MyData " & MyData Next Next Finding no# child objects of a web table in a page Set ObjTable=Description.Create ObjTable("html tag").value="TABLE" ObjTable("text").value=".*" Set TotObjTable=Browser("Gmail: Email from Google").Page("Gmail Inbox").ChildObjects(ObjTable) NoOfTables=TotObjTable.count Print "NoOfTables " & NoOfTables QTP - Descriptive program with respect to a Web Table Set ObjTable=Description.Create ObjTable("html tag").value="TABLE" ObjTable("text").value=".*" Set TotObjTable=Browser("Gmail: Email from Google").Page("Gmail Inbox").ChildObjects(ObjTable) NoOfTables=TotObjTable.count Print "NoOfTables " & NoOfTables For i=0 to NoOfTables-1 TabName=TotObjTable(i).GetROProperty("name") TabCols=TotObjTable(i).GetROProperty("cols") TabRows=TotObjTable(i).GetROProperty("rows") TabText=TotObjTable(i).GetROProperty("text") Print "TabName "& TabName Print "TabCols "& TabCols Print "TabRows "& TabRows Print "TabText "& TabText Next Get Row no# with CellText 'Get the row number for defined text Scenario : I want to get the row number where my name exists like 'GAReddy' Explanation: In my table , there are rows of data where my name could be seen. So wanted to get the number of a table where my name exists. And thus this code works there. Script: RowNumber = Browser("").Page("").WebTable("").GetRowWithCellText("GAReddy") Simmilary, in Gmail, there is InBox and if we want to get the exact row number where a specific mail (mail header) exists, then we could make use of the above code.
Retrieving all Web Table Names from a page Purpose: Retrieving all Web Table Names from a page Script: Set oTable =B().p().WebTable(html tag:=TABLE).ChildObjects Msgbox oTable .count For i=0 to oTable .count-1 Msgbox I && oTable (i).GetROProperty(name) Next
ChatGPT Side Hustles 2024 - Unlock the Digital Goldmine and Get AI Working for You Fast with More Than 85 Side Hustle Ideas to Boost Passive Income, Create New Cash Flow, and Get Ahead of the Curve
ChatGPT Money Machine 2024 - The Ultimate Chatbot Cheat Sheet to Go From Clueless Noob to Prompt Prodigy Fast! Complete AI Beginner’s Course to Catch the GPT Gold Rush Before It Leaves You Behind
ChatGPT Millionaire 2024 - Bot-Driven Side Hustles, Prompt Engineering Shortcut Secrets, and Automated Income Streams that Print Money While You Sleep. The Ultimate Beginner’s Guide for AI Business