Converting a DOM object to QTP Test Object - QTP

The HTML DOM sourcelndex property is the index value of an object in the DOM tree and can be used to get its corresponding QTP Test Object. The following code shows various techniques for getting a DOM sourcelndex:

'Getting the sourcelndex
'using the QTP Objects + DOM
srclndex = Browser("").Page("").WebEdit("").Object.sourcelndex
'Using QTP only
srclndex = Browser ("""). Page(""). WebEdit (" ").GetROProperty ("attribute/ sourcelndex")
'Using QTP only
srclndex = Browser ("*"). Page(""). WebEdit(" "). GetROProperty ("source_Index")
'Using DOM only
Set oText = document.getElementsByName(""txt_name") (0)
srclndex = oText.sourcelndex

Once we have the sourcelndex and know what type of object we are working with we can then use the following code:

'Get the webedit using source index
Browser("") .Page("").WebEditC"source_Index =" &srclndex) .Set "Test"
Browser("").Page("").WebEdit("sourceIndex=" &srclndex).Set "Test"

All rights reserved © 2020 Wisdom IT Services India Pvt. Ltd Protection Status

QTP Topics