What is DOM?
The Document Object Model (DOM) is a cross-platform and language-independent convention for representing and interacting with objects in HTML, XHTML and XML documents. Aspects of the DOM (such as its "Elements") may be addressed and manipulated within the syntax of the programming language in use. The public interface of a DOM is specified in its application programming interface (API).
how the browser display's objects in the browser
DOM
|-> Window
|-> Document
|-> Anchor
|-> Link
|-> Form
|-> Text-box
|-> Text Area
|-> Radio Button
|-> Check Box
|-> Select
|-> Button
QTP will be able to access to Internet Explorer Document Object Model (DOM) through which we will be able to access the HTML tags directly. Access to the DOM is performed using the .Object notation.
below function explains how to iterate all the tags in an Internet Explorer page. The function then outputs the inner-text of the tags (the text contained between the tags) to the Test Results using the Reporter object.
' we are using On Error Resume Next option because all the page elements might not 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
The Document Object Model (DOM) is a cross-platform and language-independent convention for representing and interacting with objects in HTML, XHTML and XML documents. Aspects of the DOM (such as its "Elements") may be addressed and manipulated within the syntax of the programming language in use. The public interface of a DOM is specified in its application programming interface (API).
how the browser display's objects in the browser
DOM
|-> Window
|-> Document
|-> Anchor
|-> Link
|-> Form
|-> Text-box
|-> Text Area
|-> Radio Button
|-> Check Box
|-> Select
|-> Button
QTP will be able to access to Internet Explorer Document Object Model (DOM) through which we will be able to access the HTML tags directly. Access to the DOM is performed using the .Object notation.
below function explains how to iterate all the tags in an Internet Explorer page. The function then outputs the inner-text of the tags (the text contained between the tags) to the Test Results using the Reporter object.
' we are using On Error Resume Next option because all the page elements might not 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
No comments:
Post a Comment