Forum Discussion

Udayreddy_90's avatar
Udayreddy_90
Contributor
12 years ago

How to Test Number of 'Links' in a page.

How can I find the no.of  links present in page.( using script ) 

3 Replies

  • Hi uday,



    Here's an example:



    function test()

    {

      var page = Sys.Process("iexplore").Page("*");

      Log.Message(getLinksCount(page));  

    }



    function getLinksCount(page)

    {

      var links = page.FindAllChildren("ObjectType", "Link", 9000);

      links = (new VBArray(links)).toArray();

      var linkscount = 0;

      linkscount = links.length;  

      return linkscount;

    }

  • Hi uday,



    Here's the VBScript version of the routine:

    Sub Test

      Dim Page

      Set Page = Sys.Process("iexplore").Page("*")

      Log.Message GetLinksCount(Page)  

    End Sub



    Function GetLinksCount(page)

      Dim Links, LinksCount

      Links = page.FindAllChildren("ObjectType", "Link", 9000)

      LinksCount = 0

      LinksCount = UBound(Links)  

      GetLinksCount = linkscount

    End Function