Facebook

For any corporate training requirements Please mail To sudhakar@qtpsudhakar.com
New Schedule in MindQ Systems, Madhapur By SUDHAKAR
Course Name Date Time Duration Type Branch
Selenium+Appium 16th October 2017 7.30 AM - 9.00 AM IST 45 Days ClassRoom + Online Mind Q Madhapur
Selenium+Appium 30th October 2017 9.30 AM - 11.00 AM IST 45 Days ClassRoom + Online Mind Q Madhapur

A book "Cracking the QTP interview" authored by Sudhakar.Read More. Buy From FlipKart

Thursday, May 28, 2009

Working with links Using DOM


Click Here to read a brief description about Document Object Model

'********************************************************************************

'********************************************************************************
'Print All Link Names From a Page

Function fnGetAllLinkNames(oParentObject)

    Dim lnkObjects
    Dim lnk   
   
    set lnkObjects=oParentObject.Object.getElementsByTagName("a")    ' A is the tag name to create  Links in HTML
    print "Total Number of links in the Page :- "&lnkObjects.length
   
    For each lnk in lnkObjects
        print lnk.outerText
    Next

    Set lnkObjects= Nothing
    Set lnk=Nothing

End Function

'Calling the Function with a parent object
Set oParentObject=Browser("Google").Page("Google")
fnGetAllLinkNames(oParentObject)

'********************************************************************************

'********************************************************************************

'Click on a specified Link

Function fnClickLink(
oParentObject,LnkName)

    Dim lnkObjects
    Dim lnk

    set lnkObjects=oParentObject.Object.getElementsByTagName("a")
       
    For each lnk in lnkObjects

        If lcase(lnk.outerText)=lcase(LnkName) then
            lnk.click
            Exit for
        End If

    Next

    Set lnkObjects= Nothing
    Set lnk=Nothing

End Function

'Calling the Function with Parent and with link name Images
Set oParentObject=Browser("Google").Page("Google")
fnClickLink oParentObject,"Images"

'********************************************************************************

'********************************************************************************

No comments :

Post a Comment