Ranorex fails to find element until retry

Bug reports.
ksanowski
Posts: 3
Joined: Fri May 24, 2019 5:29 pm

Ranorex fails to find element until retry

Post by ksanowski » Fri May 24, 2019 6:09 pm

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.
You do not have the required permissions to view the files attached to this post.

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Re: Ranorex fails to find element until retry

Post by Support Team » Mon May 27, 2019 9:14 am

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

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

Re: Ranorex fails to find element until retry

Post by odklizec » Mon May 27, 2019 9:24 am

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

ksanowski
Posts: 3
Joined: Fri May 24, 2019 5:29 pm

Re: Ranorex fails to find element until retry

Post by ksanowski » Wed May 29, 2019 10:51 pm

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]/...