5/8/2018 UFT/QTP – HTML DOM | AUTOMATION TUTORIAL
Search for:
Search
Online Tutorial
UFT/QTP – Home (http://www.automationtutorial.com/qtpuft/qtp-tutorial/)
UFT/QTP – Introduction (http://www.automationtutorial.com/qtpuft/introduction-to-hp-uni ed-functional-
testing-uft/)
UFT/QTP – Automated Testing Process (http://www.automationtutorial.com/qtpuft/uftqtp-automated-
testing-process/)
UFT/QTP – Installation (http://www.automationtutorial.com/qtpuft/uftqtp-installation/)
UFT/QTP – Quick Test Window (http://www.automationtutorial.com/qtpuft/qtp-quick-test-window/)
UFT/QTP – Record and Playback (http://www.automationtutorial.com/qtpuft/uftqtp-record-and-playback/)
UFT/QTP – Modes of Recording (http://www.automationtutorial.com/qtpuft/uftqtp-modes-of-recording/)
UFT/QTP – Object Repository (http://www.automationtutorial.com/qtpuft/uftqtp-object-repository/)
UFT/QTP – Object Identi cation (http://www.automationtutorial.com/qtpuft/uftqtp-object-identi cation/)
UFT/QTP – Actions (http://www.automationtutorial.com/qtpuft/uftqtp-actions/)
UFT/QTP – Check Points (http://www.automationtutorial.com/qtpuft/uftqtp-check-points/)
UFT/QTP – Parameterization (http://www.automationtutorial.com/qtpuft/uftqtp-parameterization/)
UFT/QTP – Output Values (http://www.automationtutorial.com/qtpuft/uftqtp-output-values/)
http://www.automationtutorial.com/qtpuft/uftqtp-html-dom/ 1/8
5/8/2018 UFT/QTP – HTML DOM | AUTOMATION TUTORIAL
UFT/QTP – Synchronization (http://www.automationtutorial.com/qtpuft/uftqtp-synchronization/)
UFT/QTP – VBScript Tutorial Part -1 (http://www.automationtutorial.com/qtpuft/uftqtp-vbscript-tutorial-
part-1/)
UFT/QTP – VBScript Tutorial Part -2 (http://www.automationtutorial.com/qtpuft/uftqtp-vbscript-tutorial-
part-2/)
UFT/QTP – VBScript Tutorial Part -3 (http://www.automationtutorial.com/qtpuft/uftqtp-vbscript-tutorial-
part-3/)
UFT/QTP – VBScript Tutorial Solved Examples (http://www.automationtutorial.com/qtpuft/uftqtp-vbscript-
tutorial-solved-examples/)
UFT/QTP – Debugging (http://www.automationtutorial.com/qtpuft/uftqtp-debugging/)
UFT/QTP – Error Handling (http://www.automationtutorial.com/qtpuft/uftqtp-error-handling/)
UFT/QTP – Recovery Scenario (http://www.automationtutorial.com/qtpuft/uftqtp-recovery-scenario/)
UFT/QTP – Regular Expression (http://www.automationtutorial.com/qtpuft/uftqtp-regular-expression/)
UFT/QTP – Descriptive Programming (http://www.automationtutorial.com/qtpuft/uftqtp-descriptive-
programming/)
UFT/QTP – Working with Data Table & Excel Object Model
(http://www.automationtutorial.com/qtpuft/uftqtp-working-with-data-table-excel-object-model/)
UFT/QTP – Windows and Web Objects (http://www.automationtutorial.com/qtpuft/uftqtp-windows-and-
web-objects/)
UFT/QTP – HTML DOM (http://www.automationtutorial.com/qtpuft/uftqtp-html-dom/)
UFT/QTP – Automation Object Model (http://www.automationtutorial.com/qtpuft/uftqtp-automation-
object-model/)
(http://www.automationtutorial.com/category/qtpuft/)
Tags
http://www.automationtutorial.com/qtpuft/uftqtp-html-dom/ 2/8
5/8/2018 UFT/QTP – HTML DOM | AUTOMATION TUTORIAL
AOM (http://www.automationtutorial.com/tag/aom/)
Automation Object Model (http://www.automationtutorial.com/tag/automation-object-model/)
Automation Process (http://www.automationtutorial.com/tag/automation-process/)
Automation Testing Process (http://www.automationtutorial.com/tag/automation-testing-process/)
Basics of Java (http://www.automationtutorial.com/tag/basics-of-java/)
CheckPoint (http://www.automationtutorial.com/tag/checkpoint/) Debugging (http://www.automationtutorial.com/tag/debugging/)
Descriptive Programming (http://www.automationtutorial.com/tag/descriptive-programming/)
HTML DOM (http://www.automationtutorial.com/tag/html-dom/)
Java Interview Questions (http://www.automationtutorial.com/tag/java-interview-questions/)
Object Repository (http://www.automationtutorial.com/tag/object-repository/)
OOPS interview Questions and Answers (http://www.automationtutorial.com/tag/oops-interview-questions-and-
answers/)
Parameterization (http://www.automationtutorial.com/tag/parameterization/) QTP (http://www.automationtutorial.com/tag/qtp/)
QTP Actions (http://www.automationtutorial.com/tag/qtp-actions/)
QTP Data Table (http://www.automationtutorial.com/tag/qtp-data-table/)
QTP Download (http://www.automationtutorial.com/tag/qtp-download/) QTP Excel (http://www.automationtutorial.com/tag/qtp-excel/)
QTP Installation (http://www.automationtutorial.com/tag/qtp-installation/)
QTP Introduction (http://www.automationtutorial.com/tag/qtp-introduction/)
QTP Object Identi cation (http://www.automationtutorial.com/tag/qtp-object-identi cation/)
QTP Output Values (http://www.automationtutorial.com/tag/qtp-output-values/)
QTP Recording Mode (http://www.automationtutorial.com/tag/qtp-recording-mode/)
QTP Tutorial
(http://www.automationtutorial.com/tag/qtp-tutorial/)
Quick Test Window (http://www.automationtutorial.com/tag/quick-test-window/)
Recovery Scenario (http://www.automationtutorial.com/tag/recovery-scenario/)
Selenium Home (http://www.automationtutorial.com/tag/selenium-home/)
Selenium IDE (http://www.automationtutorial.com/tag/selenium-ide/)
http://www.automationtutorial.com/qtpuft/uftqtp-html-dom/ 3/8
5/8/2018 UFT/QTP – HTML DOM | AUTOMATION TUTORIAL
Selenium Interview Questions & Answers (http://www.automationtutorial.com/tag/selenium-interview-questions-
answers/)
Selenium Tutorial
(http://www.automationtutorial.com/tag/selenium-
tutorial/)
selenium WebDriver (http://www.automationtutorial.com/tag/selenium-webdriver/)
Syncronization (http://www.automationtutorial.com/tag/syncronization/) UFT Actions (http://www.automationtutorial.com/tag/uft-actions/)
UFT Download (http://www.automationtutorial.com/tag/uft-download/) UFT Installation (http://www.automationtutorial.com/tag/uft-installation/)
UFT Introduction (http://www.automationtutorial.com/tag/uft-introduction/)
UFT Object Identi cation (http://www.automationtutorial.com/tag/uft-object-identi cation/)
UFT Record and Play (http://www.automationtutorial.com/tag/uft-record-and-play/)
UFT Tutorial
(http://www.automationtutorial.com/tag/uft-tutorial/)
VBScript (http://www.automationtutorial.com/tag/vbscript/)
VBScript Tutorial (http://www.automationtutorial.com/tag/vbscript-tutorial/)
UFT/QTP – HTML DOM
The Document Object Model (DOM) is an application progamming interface (API) developed by the World
Wide Web Consortium (W3C) to create and modify HTML pages and XML documents. The document
object model can be used with any programming or scripting languages.
HTML DOM – A Standard object model for HTML documents
XML DOM – A Standard object model for XML documents
DOM is especially useful for indenidentifying:
Event Handlers
Parent Nodes
Previous and Next Elements
Ready State
Source Index
http://www.automationtutorial.com/qtpuft/uftqtp-html-dom/ 4/8
5/8/2018 UFT/QTP – HTML DOM | AUTOMATION TUTORIAL
When we cannot use DOM?
Not for Browser Compatibility Testing
Not for FireEvents
Not for Edit Box, Combo Box Validation
HTML DOM Objects
A HTML document is made up of frames, Tables, Links, Buttons and Input Data elds.. etc. But when it
comes to DOM, every object is a node in a HTML document. The relations between the nodes are parent,
children, previous sibling and next sibling.
A UFT for every web object there is a property called “object”. Using this property the internal methods and
properties can be accessed for any web object.
Syntax: WebObjectClass(“PropertyName:=PropertyValue”).Object
Creating document object for IE (Without UFT)
Set IE = CreateObject(“internetexplorer.application”)
IE.Visible = True
IE.Navigate = “http://google.co.in”
Set PageObject = IE.Document
Creating document object (With UFT)
Set docObj = Browser(“browser”).Page(“page”).Object.Document
Properties
activeElement Property – Retrieves the object that has the focus when the parent document has focus.
cookie Property – Sets or retrieves the string value of a cookie.
documentElement Property – Retrieves a reference to the root node of the document.
readyState Property – Retrieves a value that indicates the current state of the object.
URL Property – Sets or retrieves the URL for the current document.
http://www.automationtutorial.com/qtpuft/uftqtp-html-dom/ 5/8
5/8/2018 UFT/QTP – HTML DOM | AUTOMATION TUTORIAL
URLUnencoded Property – Retrieves the URL for the document, stripped of any character encoding.
Collections
all – Returns a reference to the collection of elements contained by the object.
frames – Retrieves a collection of all window objects de ned by the given document or de ned by the
document associated with the given window.
images – Retrieves a collection, in source order, of img objects in the document.
links – Retrieves a collection of all objects that specify the HREF property and all area objects in the
document.
Methods
getElementById Method – Returns a reference to the rst object with the speci ed value of the ID
attribute.
getElementsByName Method – Retrieves a collection of objects based on the value of the NAME
attribute.
getElementsByTagName Method – Retrieves a collection of objects based on the speci ed element
name.
A Sample HTML Document Code
<HTML>
<title>Sample Document</title>
<body>
<h2>A Sample HTML Page</h2>
<a href=”http://www.automationtutorial.com/”>Automationtutorial.com</a>
<a href=”http://www.hp.com/”>HP</a>
</body>
</HTML>
http://www.automationtutorial.com/qtpuft/uftqtp-html-dom/ 6/8
5/8/2018 UFT/QTP – HTML DOM | AUTOMATION TUTORIAL
Accessing HTML element using DOM
Dim docObj, objIndex
Set docObj = Browser(“Sample Document”).Page((“Sample
Document”).Object.getElementsByTagName(“a”)
msgbox domObj.length
for objIndex=0 to docObj .length-1
msgbox domObj(objIndex).href
Next
Leave a Reply
Your email address will not be published. Required elds are marked *
Comment
Name *
http://www.automationtutorial.com/qtpuft/uftqtp-html-dom/ 7/8
5/8/2018 UFT/QTP – HTML DOM | AUTOMATION TUTORIAL
Email *
Website
Post Comment
© Copyright 2016. All Rights Reserved by Automationtutorial.com
Home (http://www.automationtutorial.com/) About (http://www.automationtutorial.com/about/)
Contact Me (http://www.automationtutorial.com/contact-me/)
http://www.automationtutorial.com/qtpuft/uftqtp-html-dom/ 8/8