Wednesday, October 7, 2015

How to verify the text into the Whole WebPage

set objpage = Browser("Google").Page("Google")

set objpage = Browser("Google").Page("Google")


msgbox   VerifyTextPresentOnPage(objpage ,"zeeshan" )

'-----------------------------------------------------------------------------------------------------------------------------
'Functioen name : VerifyTextPresentOnPage

'Created by  : Zeeshan Khan

'--------------------------------------------------------------------------------------------------------------------------------
Function VerifyTextPresentOnPage(objpage ,Textvalue )


'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].*"

'Get ALL child object
set allobj = objpage.ChildObjects(childobjdes)
'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
'now compare the value if the given value find or not
print output
If instr(1,lcase(output),lcase(Textvalue)) > 0  Then
'return true if found
VerifyTextPresentOnPage= True
Print VerifyTextPresentOnPage
Else
'return true if  not found
VerifyTextPresentOnPage= False
Print VerifyTextPresentOnPage
End If
End Function