gets and ID using ranorex

Ranorex Spy, Recorder, and Studio.
alexlosk
Posts: 9
Joined: Tue Oct 17, 2017 10:18 am

gets and ID using ranorex

Post by alexlosk » Tue Oct 17, 2017 10:39 am

Hi all,

I am trying to get and ID but I am not able to get it. I don't have experience with the user code, so I solution without using it would be great.

My problem comes when I try to click in a field, and this field has an ID which is always changing after refresh the website. So I tried to get this ID first without success.

My main idea is to get this id and to set it into a variable to click it. /dom[xx']//input[#set_value_input'] but I don't know how to do it.
Any idea?
Attachments
2017-10-17 11_20_20-Editing 'JournalVoucherFinanceAndOperation.InputTag1163Input'.png
2017-10-17 11_20_20-Editing 'JournalVoucherFinanceAndOperation.InputTag1163Input'.png (8.86 KiB) Viewed 404 times

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: gets and ID using ranorex

Post by Support Team » Tue Oct 17, 2017 5:47 pm

Hi Alexlosk,

While this is a possible way to overcome an element with a dynamic ID, this is not the best way to do it. When creating a RanoreXPath, you should use an attribute with a static value, not a dynamic one. If you attach a Ranorex Snapshot of your AUT, I will be more than happy to provide a better RanoreXPath.

Ranorex, by default, heavily weights the ID as a good attribute to find elements since it is usually a unique static value. If you find this ID is dynamic across your AUT, you may want to change the RanoreXPath weight rules to use different attributes. This will prevent you from having to constantly edit the auto-generated RanoreXPath.

Cheers,
Ned
.
Image