Micro Focus QTP (UFT) Forums
Can I use html id as an unique identifier for all the components in a web page - 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: VB Scripting/Descriptive Programming (https://www.learnqtp.com/forums/Forum-VB-Scripting-Descriptive-Programming)
+--- Thread: Can I use html id as an unique identifier for all the components in a web page (/Thread-Can-I-use-html-id-as-an-unique-identifier-for-all-the-components-in-a-web-page)



Can I use html id as an unique identifier for all the components in a web page - qtplearner88 - 03-16-2012

Hi,
I am facing a problem here. We are automating a web portal and we use key word driven framework. We have some libraries and we call the functions through an excel with the properties of components(button,checkbox,Link etc) as parameter.
So when I say properties, I am parameterizing any one of the property of combinations of two.

For Eg:
Code:
Function SetWebCB(setting_name,setting_value)
Browser("Browser").Page("Page") .WebCheckBox("WebCheckBox").SetTOProperty "html id",setting_name
If Browser("Browser").Page("Page").WebCheckBox("WebCheckBox").Exist Then

          If Browser("Browser").Page("Page")System").WebCheckBox("WebCheckBox").GetROProperty("disabled") = 0 Then

                         checked = Browser("Browser").Page("Page").WebCheckBox("WebCheckBox").GetROProperty("checked")

                            If  setting_value = "ON" Then

                                    If checked = 0 Then
                                            Browser("Browser").Page("Page").WebCheckBox("WebCheckBox").Set setting_value
                                            SetWebCB = 1
                                    Else
                                            SetWebCB = 0
                                            Call write_result(1,  "Object "&setting_name&" is already checked","Comments")
                                    End If

                            ElseIf setting_value = "OFF" Then

                                    If checked=1 Then
                                            Browser("Browser").Page("Page").WebCheckBox("WebCheckBox").Set setting_value
                                            SetWebCB = 1
                                    Else
                                            SetWebCB = 0
                                            Call write_result(1,  "Object "&setting_name&" is already unchecked","Comments")
                                    End If

                            Else
                                          SetWebCB = 0
                                         Call write_result(1,  "The Parameter should be either ON/OFF","Comments")
                              
                            End if

             Else
                    SetWebCB = 0
                    Call write_result(1,  "Object "&setting_name&" is disabled","Comments")
            End If
    
Else
       SetWebCB = 0
     Call write_result(1, "Object "&setting_name&" does not exist","Comments")
End If
    
End Function

In this function for checkbox I am using html id . So my doubt is that can we use html id for all the components in a portal. Will QTP identifies an object only with the help of only html id.
Please help me in this


RE: Can I use html id as an unique identifier for all the components in a web page - sshukla12 - 03-16-2012

Hi,
It's not always true that html id will give u a unique description to identify the objects in ur application.It will be better if u come up with such combinations of properties that uniquely identifies ur object.

Regards,
Sankalp


RE: Can I use html id as an unique identifier for all the components in a web page - swathi - 03-16-2012

So my doubt is that can we use html id for all the components in a portal.

NO

Will QTP identifies an object only with the help of only html id.
Please help me in this

NO

QTP may not be able to identify all the objects based on ONLY html






RE: Can I use html id as an unique identifier for all the components in a web page - sshukla12 - 03-16-2012

Hi,

U can use html id to identify the objects but make sure that it succeeds in identify the objects uniquely.

Regards,
Sankalp


RE: Can I use html id as an unique identifier for all the components in a web page - qtplearner88 - 03-16-2012

Hi Swathy,
So we will have to use some other properties to identify is it??

Thanks
qtplearner88


RE: Can I use html id as an unique identifier for all the components in a web page - swathi - 03-19-2012

Hi,

for some objects html id will be sufficient however, if we are trying to automate objects which are grouped, html id only will not be sufficient to uniquely identify the object. need to use some more object properties






RE: Can I use html id as an unique identifier for all the components in a web page - qtplearner88 - 03-20-2012

Thank u very much... So for ungrouped elements html id would be enough??that also depends rit??
Regards
qtplearner


RE: Can I use html id as an unique identifier for all the components in a web page - swathi - 03-20-2012

for ungrouped most of the time html id would be enough, eventhough we need to cross check, qtp is able to identify the object base on html id




RE: Can I use html id as an unique identifier for all the components in a web page - falvi - 05-21-2012

it is always best to have a set of properties to uniquely identify an object... using just one property for all... doesn't seem an appropriate way... each object should have properties unique to it in the application.