Micro Focus QTP (UFT) Forums
Object Name changes every time - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: UFT / QTP Beginners (https://www.learnqtp.com/forums/Forum-UFT-QTP-Beginners)
+--- Thread: Object Name changes every time (/Thread-Object-Name-changes-every-time)



Object Name changes every time - chandan.maxgit1000 - 03-24-2010

Hi,

I have one webpage,having number of checkboxes, and their name changes every time I open this webpage.

I need to set one particular checkbox.

Can any one help me out of this.

Regards:
TurtleRock


RE: Object Name changes every time - jsknight1969 - 03-25-2010

use DP to search for the text of the checkbox to set, then the name won't matter.

Code:
Dim chkobj
Set chkobj= Description.Create()
chkobj("html tag").Value = "input"
chkobj("type").Value = "checkbox"
chkobj("text").Value =  "" 'text you need here...removing this will return all checkboxes on a page as an array that you can loop through below.

dim myobjs
set myobjs = Browser("Browser").Page("Page").ChildObjects(chkobj)
myobjs.set "ON"  'change to myobjs(id).Set "ON" if returning an array of objects.
the above code might not be perfect. I have 5 or 6 functions in a framework that combine functionality to return arrays of objects from the pages and then make decisions on which one I am looking for based on multiple critieria, so I had to strip all that down into this simple code. Hope this helps and points you in the right direction.