Sunday, November 28, 2010

Unknown QTP Webtable Methods

The below listed unknown QTP webtable methods were present in Astra LoadTest. But we are still able to use these methods in QTP. I would like to share this to you.

#1 CellText
This method works as same as GetCellData method.
Eg.: Msgbox Browser("name:=qtp").WebTable("index:=0").CellText(1,1)

#2 CellTextByContext
This method returns the text within a cell delimited by a character. We can retrieve the text before (or) after the delimiter using this method.
Eg.: Consider a cell having the text “Asiq;Ahamed”. Here “;’ is the delimiter

Code to retrieve the text before the delimiter
Msgbox Browser("name:=qtp").WebTable("index:=0").CellTextByContext(1,1,"",";")

Code to retrieve the text after the delimiter
Msgbox Browser("name:=qtp").WebTable("index:=0").CellTextByContext(1,1,";")

#3 TextCellExist

This method checks whether a text exists in a cell or not. It returns true, if the input text exists in the cell, else it returns false. Rather than using GetCellData method and then comparing the result with the input text, we can achieve it using this simple method.
Msgbox Browser("name:=qtp").WebTable("index:=0").TextCellExist(1,1,"asiq")
I hope this is useful to all.

2 comments: