How can I access HTML tags directly?

Posted by rajivkumarnandvani on June 3, 2010

QuickTest provides direct access to the browser’s Document Object Model
(DOM) through which you can access the HTML tags directly. Access to the
DOM is performed using the .Object notation.
The test below demonstrates how to iterate over all the tags in a page. The
test then outputs the inner-text of the tags (the text contained between the
tags) to the Test Results using the Reporter object.
‘ Use the on error because not all the elements have inner-text.

On Error Resume Next
Set Doc = Browser(“CNN Interactive”).Page(“CNN Interactive”).Object
‘ Loop through all the objects in the page.
For Each Element In Doc.all
TagName = Element.TagName ‘ Get the tag name.
InnerText = Element.innerText ‘ Get the inner text.
‘ Write the information to the test results.
Reporter.ReportEvent 0, TagName, InnerText


One Response to “How can I access HTML tags directly?”

  1. Anonymous said

    Thank you very much 🙂 it saved me today

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: