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

Descriptive Programming for Checkpoint for Webtable

Function Created Using Descriptive Programming for Checkpoint:


Function VerifyTextPresentOnPage(byval objPage, byval Textvalue)
On error resume next

    'Create child object description
    Set childobjdes = Description.Create()
    childobjdes("micclass").value="WebTable"
    childobjdes("html tag").value=".*[A-Za-z0-9].*"
   
    'Create 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")
        print output
       
    Next
   
    'now compare the value if the given value find or not
    If instr(1,lcase(output),lcase(Textvalue)) > 0  Then
        'return true if found
        VerifyTextPresentOnPage= True
    Else
        'return true if  not found
        VerifyTextPresentOnPage= False
    End If
    On Error GoTo 0
End Function

Spring Boot : Exception Handler 14