Page 1 of 1

Ranorex fails to find element until retry

Posted: Fri May 24, 2019 6:09 pm
by ksanowski
System: Win 8.1 Professional
Ranorex Version: 9.0.1
Let me know if you need more info.

Ranorex will search for an element until its timeout, fail, then (if in maintenance mode) I will hit retry without changing anything, and Ranorex finds the element within a second. I'm assuming this means Ranorex was capable of finding the element but something was going wrong during the earlier search.

This issue was happening with other elements as well but I converted the actions to user code and changed them a bit which fixed the issue. The search only fails when performed for an action added through the "Add new action" dropdown, not the way I write them as a user code action.

For this code, the search fails until retry via maintenance mode (then succeeds immediately):
            Report.Log(ReportLevel.Info, "Wait", "Waiting 1.5m to exist. Associated repository item: 'HiMS.Psych_Eval.Tab_1.Wait_For_Psych_Eval_History_Table'", repo.HiMS.Psych_Eval.Tab_1.Wait_For_Psych_Eval_History_TableInfo, new ActionTimeout(90000), new RecordItemIndex(5));
            repo.HiMS.Psych_Eval.Tab_1.Wait_For_Psych_Eval_History_TableInfo.WaitForExists(90000);
For this code, the search is successful (different element but the same issue occurred for this one until I started performing it this way with user code):
public void Start_time_text(RepoItemInfo r)
    string p = r.AbsolutePath.ToResolvedString();
    InputTag tag = Ranorex.Host.Local.FindSingle<InputTag>(p);
    Report.Log(ReportLevel.Info, "Keyboard", "Key sequence: " + progressNoteStartTime + ".");
    tag.PressKeys(progressNoteStartTime);
I can't attach a snapshot as it contains a lot of customer info but can provide a few screenshots. If there's anything else I can add that might help, let me know.

Re: Ranorex fails to find element until retry

Posted: Mon May 27, 2019 9:14 am
by Support Team
Hello ksanowski,

Thank you for your post.

This might be a timing issue. Please ensure your page is fully loaded before accessing the mentioned element, e.g. add a Delay(). Furthemore, please try disabling the caching of all parent elements: repo element -> Properties (F4) -> Use cache = false

I hope this information helps.

Sincerely,
Robert

Re: Ranorex fails to find element until retry

Posted: Mon May 27, 2019 9:24 am
by odklizec
Hi,
Additionally, to what Robert suggested, I would suggest to remove all indexes from the failing repo element's xpath. Indexes are very unstable identification attributes and you should really consider dropping them and eventually, replace them with something else. Unfortunately, without snapshot, there is not much else anyone here can do or suggest.

Re: Ranorex fails to find element until retry

Posted: Wed May 29, 2019 10:51 pm
by ksanowski
As always, Odklizec, your help has been perfect.

I initially added the index numbers to my RxPath to improve search time but removing them fixed my issue. For the future, I will just use .../div/... instead of .../div[2]/...