Friday, 3 March 2017

InProcess: Finding Particular element on Webpage

'Function to Find Particular Object Type

'Option Explicit

Function UDF_VerifyItem(objpage,micclass,michtmltag,expectedvalue)

Dim Odesc,objallitems,i
Set Odesc=Description.Create
Odesc("micclass").value=micclass
Odesc("html tag").value=michtmltag

Set objallitems=objpage.ChildObjects(Odesc)

'msgbox objallitems.count
'msgbox expectedvalue

For i = 1 To objallitems.count Step 1

'print objallitems(i).GetROProperty("innertext")
If objallitems(i).Getroproperty("innetext")=expectedvalue Then
            UDF_VerifyItem=True
           
           
            Exit For
            Else
            UDF_VerifyItem=False
            End If
Next
End Function

Dim objpage
Set objpage=Browser("Michael Clark learns to").Page("Michael Clark learns to")

'Browser("Michael Clark learns to").Page("Michael Clark learns to").ChildObjects(Odesc)
'

'Searchtext= UDF_VerifyItem(objpage,micclass,michtmltag,expectedvalue)

Dim expectedvalue
expectedvalue="Michael Clark learns.*"
Searchtext= UDF_VerifyItem(objpage,"WebElement","H1",expectedvalue)

                If Searchtext=True Then
                    Reporter.ReportEvent micPass,"Search For  "&expectedvalue ,"Search Passed"
               
                Else
                Reporter.ReportEvent micFail,"Search For  "&expectedvalue ,"Search Failed"
                End If

No comments:

Post a Comment

Spring Boot : Exception Handler 14