Student Mode Code Display

Welcome to the Fraternity!

Commenting has been enabled. You can comment on all the Code Items now.

All About WebTable Handling in QTP


Add This Code to My Favourite List
Enter Email

Contributed By IT Prof
Date 2016-03-20 01:03:22

'Tutorial: itprof_tut
'Detail: Code to perform Basic and Advanced Web table Operations
'URL: www.itprofessionalacademy.in/demo_site/web_table/index.html
'Author: Akash

'1. Row Count and Column Count
' In column count column number sshould be mentioned
' as different row can have different columns in HTML Web table implementation
sClmCnt = Browser("title:=.*Multiple.*").Page("title:=.*Multiple.*").WebTable("html id:=tg-8nE6U").ColumnCount(1)
sRowCnt = Browser("title:=.*Multiple.*").Page("title:=.*Multiple.*").WebTable("html id:=tg-8nE6U").RowCount
sTemp = 0

'2. To Add Amount Column Values
For i=1 to sRowCnt-1
	sTemp = Split(Browser("title:=.*Multiple.*").Page("title:=.*Multiple.*").WebTable("html id:=tg-8nE6U").GetCellData(i+1,4),"$")(1) + sTemp
Next
msgbox "$"&sTemp

'3. To get Row Number of the Cell based on Cell Text
Print Browser("title:=.*Multiple.*").Page("title:=.*Multiple.*").WebTable("html id:=tg-8nE6U").GetRowWithCellText("Stationary")

'4. Traverse  Web Table cell by cell
For i= 1 to sRowCnt
	For j=1 to sClmCnt
		sTemp =  (Browser("title:=.*Multiple.*").Page("title:=.*Multiple.*").WebTable("html id:=tg-8nE6U").GetCellData(i,j)) & "," & sTemp
	Next
	Print(sTemp)
Next

'5. Child Item Method Usage
Set obj = Browser("Multiple Object with same").Page("Multiple Object with same").WebTable("Ref. No.").ChildItem(6,5,"WebEdit",0)
obj.Set "$5000"

'Function to set amount and coment in which user has issue
'using GetRowWithCellText and ChilItem
FncSetEditBoxValues "Broad band","5000","Correct Amount"
FncSetEditBoxValues "Books","5000","Correct Amount"

Function FncSetEditBoxValues(sRefNum,sAmnt,sComment)
	
	sRow =  Browser("Browser").Page("Page").WebTable("TransactionTable").GetRowWithCellText(sRefNum)
	Set oWebEdit_Amnt = Browser("title:=.*Multiple.*").Page("title:=.*Multiple.*").ChildItem(sRow,5,"WebEdit",0)
	Set oWebEdit_Cmnt = Browser("title:=.*Multiple.*").Page("title:=.*Multiple.*").ChildItem(sRow,5,"WebEdit",1)
	
	oWebEdit_Amnt.Set sAmnt
	oWebEdit_Cmnt.Set sComment
	
End Function


'6. Read all cell values in a row, concatnate each value of that row
'and set it comments section of corresponding row
'URL:http://www.itprofessionalacademy.in/demo_site/web_table/index.html
sRowCount = Browser("title:=.*Multiple.*").Page("title:=.*Multiple.*").WebTable("html id:=tg-8nE6U").RowCount
sClmCount = Browser("title:=.*Multiple.*").Page("title:=.*Multiple.*").WebTable("html id:=tg-8nE6U").ColumnCount(1)

For i=2 to sRowCount
	temp = ""

	 For j=1 to sClmCount-1
		temp = Browser("title:=.*Multiple.*").Page("title:=.*Multiple.*").WebTable("html id:=tg-8nE6U").GetCellData(i,j)
	 Next
	 
	Set oChildItem = Browser("title:=.*Multiple.*").Page("title:=.*Multiple.*").WebTable("html id:=tg-8nE6U").ChildItem(i,5,"WebEdit",1)
	oChildItem.Set temp
Next


'7. Using Child Objects in Web table
Set oDesc = Description.Create
oDesc("micClass").value = "WebEdit"

Set oChild = Browser("title:=.*Multiple.*").Page("title:=.*Multiple.*").WebTable("html id:=tg-8nE6U").ChildObjects(oDesc)
For i=1 to oChild.Count
	temp = Browser("title:=.*Multiple.*").Page("title:=.*Multiple.*").WebTable("html id:=tg-8nE6U").GetCellData(i,2)
	oChild(i-1).Set i
Next

Download Above Code

Comments:



Add your comments...
Name : *      
Email : *      
The content of this field will be kept private and will not be shown publicly

Your Comment/Answer *

Enter the text present in this box : *