Accessing HTML tags directly using QTP
Question ID: 104035

Is there a way to Access HTML tags directly using QTP and loop through all the objects on the page?

Marked as spam
Posted by (Questions: 4, Answers: 0)
Asked on February 5, 2010 6:52 pm
Answers (1)
Private answer

QuickTest provides direct access to the browser's Document Object Model (DOM) through which you may access the HTML tags directly. Access to the DOM is done using the .object notation. You can find more information about the DOM on the Microsoft Web Workshop web site. See

The test below demonstrates how to iterate over all the tags in the page. The test then outputs the inner-text of the tags (the text contained between the tags) to the report using the Reporter object.

'We need the on error because not all the elements have inner-text

On Error Resume Next
Set Doc = Browser(''Test Page Title'').Page(''Test Page Title'').Object

'Loop through all the objects in the page
For Each Element In Doc.all      
    TagName   = Element.TagName    
        ' Get the value for the tag ('I am using innerText')   
    InnerText = Element.innerText  
        ' Write the information to the report     
    Reporter.ReportEvent 0, TagName, InnerText 
Marked as spam
Posted by (Questions: 6, Answers: 167)
Answered on February 5, 2010 11:33 pm
Also see for the distinction between the W3C DOM and the DHTML Object Model.
( at March 24, 2010 2:01 am)

Welcome back to "EyeOnTesting" brought to you by Orasi Software, Inc.

Scroll to Top