HTML tag vague

Technology specific object identification, supported applications, web technologies, and 3rd party controls.
QATest879
Posts: 31
Joined: Fri Jul 02, 2021 2:35 pm

HTML tag vague

Post by QATest879 » Tue Oct 26, 2021 2:48 pm

I'm doing a Ranorex project with HTML now, and I'm noticing a lot of elements are named div[2] or li[3] etc. on the Ranorex path by default.

Giving the web elements a vague index like this works I suppose, but what if something on the website changes slightly and div[2] becomes div[3]? Will I need to readjust my test every time that happens? Or does this problem not happen? I'm wondering what can be done to make the path more specific than element-type[indexnumber] so that it's more reliable.

I'm not sure how though, sometimes I need to click a particular checkbox on a list of many checkboxes, so I don't really know a better way to do it than using the index number of the checkbox. Just wondering if anybody knows of any better ways to make the Ranorexpath if possible. Thanks.

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

Re: HTML tag vague

Post by odklizec » Tue Oct 26, 2021 4:06 pm

Hi,

Unfortunately, without seeing, at very least, a Ranorex snapshot, it’s hard to suggest something reliable. Indexes are of course fragile and least persistent identification attributes. What I’m doing in a similar situation, is using Ranorex relationship operators and using for example element labels or somewhat else related elements, to identify elements I want to read, write to or validate. As mentioned before, without seeing the snapshot, it’s impossible to suggest something more detailed.
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

dhale
Posts: 71
Joined: Thu Feb 27, 2014 7:33 pm

Re: HTML tag vague

Post by dhale » Wed Oct 27, 2021 8:23 pm

The default spy rx paths are pretty specific. That's where skill comes in with editing the rx path so that it is both robust and unique at the same time. Be aware that you dont need to accept the default path, you can add/edit/remove attributes on each level to get you something that is both robust, and unique at the same time. I would recommend reading through the user guide and everything it has to say about rx paths https://www.ranorex.com/help/latest/ran ... roduction/