Page 1 of 1

Convert Ranorex Path to String and update the path in runtime

Posted: Fri Aug 16, 2019 3:25 pm
by JillNarra
Hi,

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.
repository.JPG
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.

repo.MoveletStep=strMoveletStep;
repo.Movilizer.ClientMainObjects.txtMoveletStep.Element.Focus();
string strActualMoveletStep = repo.Movilizer.ClientMainObjects.txtMoveletStep.Element.GetAttributeValueText("text");
Report.Info(strActualMoveletStep);
Report.Screenshot();
if (strActualMoveletStep == strMoveletStep)
{
repo.Movilizer.ClientMainObjects.txtMoveletStep.Focus();
Delay.Seconds(1);
repo.Movilizer.ClientMainObjects.txtMoveletStep.Click();
Report.Success("Clicked on Movelet step: "+strMoveletStep);
}

Do you have an idea on this?

Thank you so much.

Best regards,
Jill

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

Posted: Mon Aug 19, 2019 7:48 am
by Stub
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?

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

Posted: Mon Aug 19, 2019 8:35 am
by odklizec
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?