Convert Ranorex Path to String and update the path in runtime

Best practices, code snippets for common functionality, examples, and guidelines.
Posts: 3
Joined: Thu Aug 15, 2019 3:52 pm

Convert Ranorex Path to String and update the path in runtime

Post by JillNarra » Fri Aug 16, 2019 3:25 pm


I hope you can help me on my issue as I have 2 objects (container) which could be selected depending on the logic of which container you want to select.
text 1.JPG
text 2.JPG
So I added and created a repository that I can call during runtime.
However, during the first execution, I am calling the first text and it is working fine. But for the second text, it is still selecting the first text.

string strActualMoveletStep = repo.Movilizer.ClientMainObjects.txtMoveletStep.Element.GetAttributeValueText("text");
if (strActualMoveletStep == strMoveletStep)
Report.Success("Clicked on Movelet step: "+strMoveletStep);

Do you have an idea on this?

Thank you so much.

Best regards,
You do not have the required permissions to view the files attached to this post.

User avatar
Posts: 474
Joined: Fri Jul 15, 2016 1:35 pm

Re: Convert Ranorex Path to String and update the path in runtime

Post by Stub » Mon Aug 19, 2019 7:48 am

I usually use repository items that have repository variables embedded within the RxPath. I then adjust the variable at runtime, which customises the repoitem. e.g. I might specify a list element as "listitem[@text=$NamedItem]" and then adjust "Repo.NamedItem = "Some Named Item";" in my code. Is that what you mean?

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

Re: Convert Ranorex Path to String and update the path in runtime

Post by odklizec » Mon Aug 19, 2019 8:35 am

Hi Jill,

Could you please upload a Ranorex snapshot (NOT screenshot) of the UI? Additionally, I think you should stop relying on element indexes, which are highly volatile and could easily break your tests. My best guess, without seeing the snapshot and complete xpaths behind the elements used in code, is that an xpath returns multiple elements and not just one? In this case, Ranorex always picks the first found element, which could be also your case? So please post the snapshot and xpaths (not screenshots of xpaths) so we can analyze them.

Maybe I'm missing something obvious, but why don't you create an xpath, based of the Text attribute, which is containing text 'Order long text' or 'Leave order processing?
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