QTP Dom

What is Document object Model?
A platform- and language-independent standard object model for representing HTML or XML and related formats.


When can we use DOM?

One of the very important places you can use it is when a QTP web table checkpoint doesn’t show you the desired content in a cell. I mean the content in the cell is in a format that is not supported by the web table checkpoint. Another use can be when you want to access all the HTML tags used in a webpage. You can get the names, the innertext, innerHTML property of all these tags. The possibilities are endless.
How can we use DOM to access the source page?

We can access the source page of any webpage using .object notation.

Any practical example of using DOM?


I have created a demo web page to show you document object model in action. Say you want to find the font color used for writing Happy Holidays Everyone in cells of the webtable given on this page. The algorithm would be:

1. Access the DOM of webtable using .object notation.
2. Access the tagname corresponding to the property you wish to find out. In our case tagname is “font” and property to be explored is “color”.

3. Find the count of total number of tags and loop it find out the font-color.

The corresponding VB script would be:

set font=Browser("B").Page("P").WebTable("H").Object.all.tags("font")

msgbox font.length

For i=0 to font.length-1
Msgbox font(i).color
next

XML Code To Get Root Child Nodes

On error resume next
Set xmlDoc = XMLUtil.CreateXML()
'loadXML
xmlDoc.LoadFile("C:\ApplyWeb_getPrescreenData.xml")
If Err.Number <> 0 Then
Msgbox "Invalid XML"
End If
Set Root = xmlDoc.GetRootElement()
Set objChildNodes = Root.ChildElements()
numberof = objChildNodes.count()
msgbox numberof
On error goto 0 

Encrypt PWD

str = "Some Text"
encrStr = Crypt.Encrypt(str)

5 comments:

  1. I like your writing style, it was very clear to understanding the concept well; I hope you ll keep your blog as updated.
    Regards,
    Loadrunner course in Chennai|Best Loadrunner training institute in chennai|Qtp training Chennai|Qtp course in Chennai

    ReplyDelete
  2. Thanks for sharing the valuable post. Kanhasoft is the well known Custom PHP Web Developer in India. We providing outsourcing services to USA, UK, Europe, Canada, Germany, UAE, Dubai, Australia, France, Brazil, Turkey, Singapore, Japan, Saudi Arabia, Ukraine, Spain, Belgium, Netherlands, Luxembourg, New Zealand, Argentina, South Africa, Greece, Denmark, Poland, Switzerland and more. Visit our site to know more.

    ReplyDelete
  3. The blog you have shared is very much helpful to know more about the selenium. Thanks for your information about the selenium.
    selenium testing training
    selenium testing course
    selenium training classes
    selenium classes
    selenium training course

    ReplyDelete