Hi All, Some Time we have to check that particular text is present on page or not during automation. If we get the page outer HTML in QTP we can not get the whole text of all element like frame , webtable . div.etc… So i created a function which will check that the given text is present on page or not If Text present on page it will return True else False
REM ——- Set page object ———-
set objpage = Browser(“BrowserName”).Page(“Pagename”) msgbox VerifyTextPresentOnPage(objpage ,”rajiv” )
Function VerifyTextPresentOnPage(byval objpage , byval Textvalue )
Here first row of table is considered as column so using getcelldata method for first row of web table
For clmNo =1 to mGetColumnCount
msgbox Browser("XYZ").Page("OBC").WebTable("Request Summary").GetCellData(1,clmNo)
Next
I found that most of time while working with WEBTABLE we need to the select the row based on some criteria by clicking checkbox or radiobutton.For that first we have to find the row which we have to select based on value of that row like text/link inside the row.
Here I am giving an example how to select a row in Webtable by finding the text. Logic I am using here is first i will find the row number from webtable where my searching text is present using GetRowWithCellText method then I will provide the column name/index of webtable where checkbox is present.
In below mentioned example I will select the row where Confirmation Number is "15204" Let's see
REM check text find in webtable or not
If GtRowN >0 Then
REM coulmn index where checkbox is present Rem here select coulmn name index value is 1 CoulmnIndex = 1 REM create the checkbox object after getting the rownumber and select the row by clicking the checkbox
set objCheckbox = Browser("XYZ").Page("OBC").WebTable("Request Summary").ChildItem(GtRowN,CoulmnIndex,"WebCheckBox",0)
objCheckbox.set "ON"
else
msgbox "Did not find the value test fail"
End If