VB Get All Web page text ( Including All Webelement )
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
msgbox VerifyTextPresentOnPage(objpage ,”rajiv” )
childobjdes(“micclass”).value=”WebElement”
childobjdes(“html tag”).value=”.*[A-Za-z0-9].*”
childobjdes(“outertext”).value =”.*[A-Za-z0-9].*”
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
Else
End If
On Error GoTo 0
End Function
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
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-1output= 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= TrueElse
rem return true if not found
VerifyTextPresentOnPage= FalseEnd If
On Error GoTo 0
End Function