preload

How to find all links on a web page (TestComplete)

Posted by Albert Gareev on Dec 15, 2012 | Categories: GUI RecognitionHow toSource codeWeb

Description

  1. Get parent object reference. In the example given, it’s a browser process, but you can narrow it down to a page or a web container object (table,  div, etc.).
  2. Use FindAllChildren to retrieve array of links.
    – You can limit search depth according to your context.
    – You may want to do filtered search using additional properties: Visible, VisibleOnScreen, ContentText, etc.

Implementation

  Dim PropNames, PropValues, IEProcess
  Dim Links

  PropNames = Array("processname", "index")
  PropValues = Array("iexplore", 1)

  Set IEProcess = Sys.FindChild(PropNames, PropValues, 1, True)

  PropNames = Array("ObjectType")
  PropValues = Array("Link")
  Links = IEProcess.FindAllChildren(PropNames, PropValues, 100, True)

  PropNames = Array("ObjectType", "Visible")
  PropValues = Array("Link", True)
  Links = IEProcess.FindAllChildren(PropNames, PropValues, 100, True)


Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported
This work by Albert Gareev is licensed under a Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported.