web elements - no unique ids

Technology specific object identification, supported applications, web technologies, and 3rd party controls.
pxmb
Posts: 7
Joined: Fri Jan 12, 2018 9:24 am

web elements - no unique ids

Post by pxmb » Mon Jan 15, 2018 2:42 pm

Hi,
I am having some significant difficulty consistently identifying some particular menu items in an iFrame.

It's about 5 Inputs:
They have all the same root but none of the parents have an unique or specific information so that it is difficult to get them identified.

Would it be possible to get them identified by the text which is shown to the left to the input field?

Input WD0584 = Beginndatum
Input WD0589 = Eingangsdatum
Input WD058E = Unterschriftsdatum
Input WD0594 = Notiz
and
Input WD05A6 = Vertriebsnummer

Screenshots attached.

----
Ranorex: 8.0.0
Windows: Windows 10 Enterprise - 10.0.14393
IE 11.1944.14393.0IS
Ranorex Add-on active
SUT: SAP
- EHP 7 FOR SAP ERP 6.0
- SAP ERP 6.0 (2005)
- SAP Netweaver 7.4
Attachments
Screenshot_Spy_TR_Beginndatum.jpg
Screenshot_Spy_TR_Beginndatum.jpg (257.91 KiB) Viewed 956 times
Screenshot_Spy_2.jpg
Screenshot_Spy_2.jpg (276.15 KiB) Viewed 956 times
Screenshot_Spy_1.jpg
Screenshot_Spy_1.jpg (280.35 KiB) Viewed 956 times

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 3930
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: web elements - no unique ids

Post by odklizec » Mon Jan 15, 2018 2:52 pm

Hi,

Could you please post a Ranorex snapshot (not screenshot) of the problematic element(s)? Screenshots are useless for evaluation of problem like yours.

Generally speaking, yes, it should be possible to identify elements by their text/other attributes or even by using other elements and some relationship operators to identify correct elements. You can even instruct Ranorex to prioritize different atributes over the default ones using Ranorex xpath weight editor (like giving InnerText attribute a priority over random ID attribute). Unfortunately, without Ranorex snapshot, it's had to tell the best strategy.
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

pxmb
Posts: 7
Joined: Fri Jan 12, 2018 9:24 am

Re: web elements - no unique ids

Post by pxmb » Mon Jan 15, 2018 3:03 pm

Hi. How can we add snapshots here? it's limited to 1MB. Compressed file has about 2MB

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 3930
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: web elements - no unique ids

Post by odklizec » Mon Jan 15, 2018 4:45 pm

Hi,

The easiest way is to use a file sharing service, like Dropbox, Google drive or similar and here post a link.
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

pxmb
Posts: 7
Joined: Fri Jan 12, 2018 9:24 am

Re: web elements - no unique ids

Post by pxmb » Wed Jan 17, 2018 11:18 am

Hi,

I've managed to capture another, similar screen with non-unique, dynamic elements.
Please find attached the snapshot for further analysis.

It's about the input fields - having all a parent named "TR"

Input WDEA = Policennummer --> /dom[@domain='paxchsv362.intern.pax.ch:1443']//iframe[#'URLSPW-0']//input[#'WDEA']
Input WDF1 = PEVA Police Typ --> /dom[@domain='paxchsv362.intern.pax.ch:1443']//iframe[#'URLSPW-0']//input[#'WDF1']
etc.

How can we ensure that those elememts get an unique identification?
Attachments
Snapshot.rxsnp
SNAPSHOT
(574.34 KiB) Downloaded 16 times
Screenshot_Non_Unique_IDs_Application.jpg
Screenshot Application
Screenshot_Non_Unique_IDs_Application.jpg (60.05 KiB) Viewed 931 times
Screenshot_Non_Unique_IDs.jpg
Screenshot Spy
Screenshot_Non_Unique_IDs.jpg (215.21 KiB) Viewed 931 times

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 3930
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: web elements - no unique ids

Post by odklizec » Wed Jan 17, 2018 12:16 pm

Hi,

Thanks for the snapshot.

At first, I would recommend to read and understand this blog post, about working with dynamic IDs:
https://www.ranorex.com/blog/automated- ... namic-ids/

Basically, you should reduce the xpath weight for webelement "ID" and increase weight of "Class" attribute. This should eliminate the usage of useless ID (during recording), which is in your case dynamic and therefore worthless. It seems the Class attribute provides somewhat more useful info?

But I'm afraid, even with these changes, there will be a lot of manual work to make the xpaths working for you. You see, after you record some actions, Ranorex will point to the element(s) with no or limited identification attributes. But luckily for you, there are labels next to each element you are interested in. So you can use these as a starting point, from which you can locate the elements you want to validate/edit.

Here are two xpaths showing what I mean:
/dom[@domain='paxchsv362.intern.pax.ch:1443']/body/iframe//div[@class~'lsPopupWindow']/div/div[@class='urPWContent']//table//label[@title='Policennummer']/ancestor::tr/td/span/input

/dom[@domain='paxchsv362.intern.pax.ch:1443']/body/iframe//div[@class~'lsPopupWindow']/div/div[@class='urPWContent']//table//label[@title='PEVA Police Typ']/ancestor::tr/td/span/input

As you can see, the xpath first finds the label containing the description of the element in question, then it goes up and finds the input belonging to the same TR tag.

Hope this helps?
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

xeronar
Posts: 28
Joined: Mon May 22, 2017 8:19 pm

Re: web elements - no unique ids

Post by xeronar » Thu Feb 08, 2018 12:21 am

Hey guys,

I don't want to open another topic with almost the same issues so I hope it's ok if I'm posting it here:
I have to test a lot different input tags, but there aren't any unique classes or IDs at all since the whole forms are generated dynamically by using JSON-templates. There are different countries and validations/regexps/placements so the tests have to be dynamic as well in order not to change everything manually if a new form got generated. The input tags look like this:

Code: Select all

<input class="a" data-bind-value="b" data-bind-attribute-id="Id" data-bind-attribute-placeholder="Placeholder" data-bind-validation="Validations" ... id="1342345" placeholder="E-Mail" ...>
<input class="a" data-bind-value="b" data-bind-attribute-id="Id" data-bind-attribute-placeholder="Placeholder" data-bind-validation="Validations" ... id="1678234" placeholder="First name" ...>
<input class="a" data-bind-value="b" data-bind-attribute-id="Id" data-bind-attribute-placeholder="Placeholder" data-bind-validation="Validations" ... id="1978934" placeholder="Last name" ...>
So "id" and "placeholder" are the only attributes which are dynamic/have different values but all the other attributes are identical to each other in every input tag, no uniqueness at all! I highly doubt that - even with weight paths - one is able to track those items just by the attributes itself (except I make the values of "placeholder" variable and store them a specific country config, but this won't be a dynamic test either for like > 20 countries, especially if validations got changed or input fields got removed).

Do you agree with me or is there any other method to automate this? It seems like that these tests should be treated as unit tests rather than UI tests.

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 3930
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: web elements - no unique ids

Post by odklizec » Thu Feb 08, 2018 9:17 am

Hi,

Well, despite similar nature of the problem, it's always better to create a separate forum post (for clarity and better readability). And as mentioned before, to be able to provide a reasonable answer, we need, at very least, a Ranorex snapshot. Could you please upload one?
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

xeronar
Posts: 28
Joined: Mon May 22, 2017 8:19 pm

Re: web elements - no unique ids

Post by xeronar » Fri Feb 09, 2018 10:32 pm

Hey odklizec,

thanks for the answer. Will open a new topic next time sorry for that. I'll try to provide you a snapshot at the beginning of the next week. But for now, we just discussed the problems how to automate such generic forms. The real challenge is that my developers don't want to manually customize the tests if the templates for the forms got changed (new input fields/input fields removed etc.).

xeronar
Posts: 28
Joined: Mon May 22, 2017 8:19 pm

Re: web elements - no unique ids

Post by xeronar » Mon Feb 12, 2018 9:50 am

Here's the snapshot.

Version: Ranorex Studio 8.0

Tracking elements via placeholder attribute works fine, but since they are not unique for every country I need to create a lot of different configurations. And if some of the placeholders will change, I need to change my configs as well, this is the case we want to prevent, customizing the tests manually.
Attachments
Recording220180212_094050_0_rxlog.rxsnp
(139.65 KiB) Downloaded 18 times

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 3930
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: web elements - no unique ids

Post by odklizec » Mon Feb 12, 2018 10:09 am

Hi,

What I'm personally doing, in some of my tests, is collecting all elements from the app configuration page (e.g. all inputs, check boxes, option boxes) and their state. Then I'm storing entire page (elements in question) in CSV file. So I don't have to create the list of elements manually. And in case there are some new elements added to the config page (or some elements are removed), I simply re-generate ref. files.

Then for validation of elements, I'm looping the reference CSV file and comparing actual state of found "live" element, with the ref. one stored in CSV. And if needed, the state of element is changed with the state stored in ref. file.
The thing is, that configuration pages in our AUT have relative good IDs, which is apparently not your case? So you will most probably have to find another way of identification of elements, e.g. using labels of given elements?

PS: nice to see another Czech using Ranorex :D
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

xeronar
Posts: 28
Joined: Mon May 22, 2017 8:19 pm

Re: web elements - no unique ids

Post by xeronar » Fri Feb 23, 2018 11:35 am

Hey,

thanks for sharing your knowledge, haven't thought of saving the whole HTML in a .csv file. Yeah in my project, it is more difficult, either I can recognize the elements by their placeholders (not best practice at all but if everything is dynamically that's the last possibility :D) and request a lot of country configurations or i need to know more about the .json files which generate the forms, thus working together with the devs more intense.

PS: Sorry but I'm not Czech, I'm German, I just thought it would be nice to give you an example in your native language :D