Path not recognized with variables

Ask general questions here.
bwood
Posts: 16
Joined: Mon Jan 28, 2019 2:52 pm

Path not recognized with variables

Post by bwood » Fri Aug 30, 2019 9:35 pm

I have a path that recently stopped working and I am going crazy trying to find out why.

Code: Select all

/form[@title~'^Select\ the\ Default\ item\ ']/descendant-or-self::*/row[@index=$varIndex]/cell[@text<=$varFileNameWithExt]
The variables are correct, when Ranorex reports the error it shows the correct values (see below). Immediately after the test fails, I can copy/paste the "broken" path from the error message into Spy and it finds the element without issue. Interestingly, if I remove the variables and set the repo path to be hardcoded it works fine.
How can a path be broken by a variable even when the variable appears to be working correctly?

I am launching the test from the test suite view, so the variable should be set correctly. Since it works without variables it is not a whitelist issue.

Failed to find item 'Main_Repo.SelectTheDefaultthingProgramDatabase.DBInWindowOne'. Please check that your whitelist allows Ranorex to access the process.
No element found for path '/form[@title~'^Select\ the\ Default\ item\ ']/descendant-or-self::*/row[@index='0']/cell[@text<='data base.accdb']' within 1m.

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

Re: Path not recognized with variables

Post by odklizec » Mon Sep 02, 2019 9:25 am

Hi,

Could you please upload a Ranorex snapshot (NOT screenshot) of the problematic element? In my opinion, there is an invisible/non-printable character either in UI or variable and therefore, Ranorex fails to find the element. Please make sure the variable string is 100% match to the one in UI. Just copy the string from UI (via Ranorex Spy) and paste it in a good text editor, where you can display all non-printable characters (or switch in ASCII mode).
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

bwood
Posts: 16
Joined: Mon Jan 28, 2019 2:52 pm

Re: Path not recognized with variables

Post by bwood » Tue Sep 03, 2019 2:56 pm

I have attached the snapshot. It is just a simple windows explorer window to select a file to open. The string appears to be a 100% match and I didn't find any hidden characters (checked in notepad++)
Attachments
novar.rxsnp
(35.94 KiB) Downloaded 3 times

manish
Posts: 45
Joined: Fri Aug 10, 2018 12:46 pm

Re: Path not recognized with variables

Post by manish » Tue Sep 03, 2019 3:07 pm

Hi,

Are you sure that you have uploaded the snapshot for the correct form because the form in question is /form[@title~'^Select\ the\ Default\ item\ '] whereas the snapshot has /form[@title>'Select the Default Meter Program'].

Please check.

Cheers
Manish

bwood
Posts: 16
Joined: Mon Jan 28, 2019 2:52 pm

Re: Path not recognized with variables

Post by bwood » Tue Sep 03, 2019 3:20 pm

Yes it is correct, I generalized the text in the initial post

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

Re: Path not recognized with variables

Post by odklizec » Tue Sep 03, 2019 3:24 pm

Hi,

Aside to what manish suggested, I would suggest to select file via its full path, instead of searching and selecting file with mouse. For more details, check this post:
https://www.ranorex.com/forum/how-to-pe ... tml#p51682
There is really no point doing FileOpen operation more complicated way, than is necessary ;)
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

bwood
Posts: 16
Joined: Mon Jan 28, 2019 2:52 pm

Re: Path not recognized with variables

Post by bwood » Tue Sep 03, 2019 3:28 pm

That makes sense - I'll check out opening via path and see if that fixes it. The mouse just seemed like the easiest option initially.

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

Re: Path not recognized with variables

Post by odklizec » Tue Sep 03, 2019 3:33 pm

The 'easiest' options often renders as much more complicated and unreliable ;)
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