WORKING WITH QTP

TestEveryThinG

Archive for October, 2009

VB Get All Web page text ( Including All Webelement )

Posted by rajivkumarnandvani on October 1, 2009

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 )
On error resume next

REM ——- Create child object description
Set childobjdes = Description.Create()
childobjdes(“micclass”).value=”WebElement”
childobjdes(“html tag”).value=”.*[A-Za-z0-9].*”
childobjdes(“outertext”).value =”.*[A-Za-z0-9].*”

REM  ———-Create ALL child object
set allobj = objpage.ChildObjects(childobjdes)
REM  get all  web element  outer text from web page and store in output variable
For i=1 to allobj.count-1
output=  output   & allobj.Item(i).GetROProperty(“outertext”)
Next
REM  now compare the value if the given value find or not
If instr(1,lcase(output),lcase(Textvalue)) > 0  Then

rem return true if found
VerifyTextPresentOnPage= True
Else

rem return true if  not found
VerifyTextPresentOnPage= False
End If
On Error GoTo
0
End Function

Posted in QTP | Tagged: , , , | 37 Comments »