krishnarik Absent Member.
Absent Member.
1973 views

html id's are changing for each time the page is loaded

Hi,
I am writing scripts for a web page, which has edit boxes and other input items which has html id as unique property.But each time the page loads,the html ids for edit boxes are changing.For e.g,say for the first time page is loaded,the html id of EditBox1 is "x-auto-97-input".When the page loads for second time the html id of Editbox1 is changed to "x-auto-92-input".

 

Is there a way to fix this? This page is rendered from javascript (Ext-GWT controls).

 

0 Likes
10 Replies
rajpes Absent Member.
Absent Member.

Re: html id's are changing for each time the page is loaded

I guess you should use "name" property instead of html id
-------------------------------------------------------------------
miracles happen when we make them happen!
0 Likes
Absent Member.. Anshoo_Arora Absent Member..
Absent Member..

Re: html id's are changing for each time the page is loaded

This behavior is caused by GWT.  Can you share the html of the source object?  There are generally other properties that you can use to uniquely identify this object each time the page loads.  If its not possible to share the source, refer the outerHTML or the class properties - you may find the solution there.


--
Anshoo Arora
Relevant Codes
LinkedIn
0 Likes
Lmac Absent Member.
Absent Member.

Re: html id's are changing for each time the page is loaded

You would need a descriptive programming to handle this dynamic value.

0 Likes
capriconsri Absent Member.
Absent Member.

Re: html id's are changing for each time the page is loaded

Use regular expression in the object repository of that particaular editbox something like...htmlid="x-auto-.*-input".

 

use regular expression evaluator if u are using qtp11.0 and make sure you are using the right regular expression and qtp recognises the object after regularisation.

0 Likes
krishnarik Absent Member.
Absent Member.

Re: html id's are changing for each time the page is loaded

I want html id's to remain constant.Is there a solution?

0 Likes
mohsenfi Absent Member.
Absent Member.

Re: html id's are changing for each time the page is loaded

Hi,

Html id is changing in your application by the java scripts, and that is how it has been designed! You can not keep it unchanged, unless your developers would change their code!

So there are two ways to get rid of this issue in QTP, as said earlier by other members:

- Use some other properties which are constant and identify the object

- If  there is no way than using html id, then you should use regular expression e.g. x-auto-.*

0 Likes
krishnarik Absent Member.
Absent Member.

Re: html id's are changing for each time the page is loaded

@mohsenfi : Could you be more specific what developers need to do or to be asked for.Thanks in advance.

0 Likes
Reju George Absent Member.
Absent Member.

Re: html id's are changing for each time the page is loaded

If the developer has put dynamic html ids then there is a reason for this. Is there any reason why you dont want to put a regular expression for the html id for identification ? 

 

The following regex should help you

 

x-auto-[0-9][0-9]-input

x-auto-[0-9]+-input

0 Likes
mohsenfi Absent Member.
Absent Member.

Re: HTML id's are changing for each time the page is loaded

As Reju said, there must be a reason that your developer did such a design. 

Anyway, you can ask your web-developer about this edit box and its HTML id, and check whether it can be kept static (it is very unluckily that they would change their design just because you can not run your automated test case 🙂 )

You should consider whether a regular expression method or using different properties which stay unchanged.

0 Likes
Absent Member.. Anshoo_Arora Absent Member..
Absent Member..

Re: html id's are changing for each time the page is loaded


@krishnarik wrote:

I want html id's to remain constant.Is there a solution?


Highly unlikely.  As I wrote in my previous post:

 

This behavior is caused by GWT.  Can you share the html of the source object?  There are generally other properties that you can use to uniquely identify this object each time the page loads.  If its not possible to share the source, refer the outerHTML or the class properties - you may find the solution there.

 

There are other ways of working with and providing unique enough descriptions for these objects. Read this post at SQAForums.com:

 

http://www.sqaforums.com/showflat.php?Cat=0&Number=678630&an=0&page=0

 

It shows a way to drill up to the parentNode to identify the childNode object. There are many other techniques which you can find when exploring HTML DOM. Straight-forward QTP techniques of object recognition may not be very helpful when working on GWT - you will have to explore parent-child relationships to analyze the HTML source and finding elements that can uniquely identify the object using these relationships.


Another way would be to use Visual Relational Identifiers as Tarun mentioned in the above link.

 


--
Anshoo Arora
Relevant Codes
LinkedIn
0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.