Friday, February 10, 2012

Common DOM methods and properties used in QTP

Every HTML element in a Web page is a scriptable object in the object model, with its own set of properties, methods, and events. To enable access to these objects, Internet Explorer creates a top-level document object for each HTML document it displays. When you use the .Object property on a Web page object in your test or component, you actually get a reference to this DOM object. This document object represents the entire page. From this document object, you can access the rest of the object hierarchy by using properties and collections.

Following are the most useful document properties and methods available through the Web .Object property:

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.
  • 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 defined by the given document or defined 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 first object with the specified 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 specified element name.

Source:Sudhakar's blog

No comments:

Post a Comment