Submitted Questions

  • Count Number of Links

    How to count number of links in a web page using QTP?

    Star Read Best Answer

    Editorial / Best Answer

    calvin_29  

    • Member Since Sep-2010 | Sep 20th, 2010


    This is the script, We should first create an object

    set oDesc=description.create()
    'prefer descriptive programming...batter
    oDesec("micclass").value="link"
    'get all child objects in an variable
    set oLink=browser("name:=.*").page("title:=.*").childobjects(oDesc)
    'count all links
    intC=oLink.count
    'Use print or msgbox or 'reporter.reportevent'
    print intC
    'it glows links in the web page
    for i=0 to intC-1
    oLink(i).highlight
    next
    set oLink=nothing
    set oDesc= nothing

    'Offer me comment if it works properly

    rohan

    • May 22nd, 2015

    By using descriptive programming we can count and displays the number of links in web page Set ObjDesc = Description.Create ObjDesc.Add "micclass","Link" Set ObjBr = Browser("name:=*).Page("title:=...

    yogi

    • Dec 27th, 2014

    Your code doesnt work on set links line it throws an error as not supported method