Multiple instances in one xpath

Ask general questions here.
965702
Posts: 14
Joined: Fri Dec 21, 2018 9:49 am

Multiple instances in one xpath

Post by 965702 » Thu Mar 07, 2019 10:14 am

Hi Guys

I have the following xpath for a component:

/form[@title~'^EXCDS\ LTC\ Workstation\ Ver']/element[@class='AfxMDIFrame100']/element[@instance='0' or @instance='1' and width()=643 and height()=1286]

I have two of the same instance that can be in different positions depending on the controlling sector. I want to have the xpath dynamic so it can choose either 1 or 0. But I'm finding the SPY sees two (great) but always goes to the instance i don't want when run. Is there another way of telling the xpath to look for two options?

Regards

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

Re: Multiple instances in one xpath

Post by odklizec » Thu Mar 07, 2019 10:22 am

Hi,

At first, without snapshot (not screenshot), it's really hard to suggest something reliable. At next, the xpath you are using is fragile and it will always show two elements, if there are elements with instance='0' and instance='1'. And if there are two or more elements found, Ranorex always uses the first found element. The only workaround could be adding the index number (of preferred element) at the end of xpath. But again, without snapshot, it's hard to tell something more reliable.
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

965702
Posts: 14
Joined: Fri Dec 21, 2018 9:49 am

Re: Multiple instances in one xpath

Post by 965702 » Thu Mar 07, 2019 10:30 am

Hi dude

I've attached a snapshot of the element and a screenshot. You can see from the jpeg i have two rectangle panels and this time i want to find "BNN PEND".
You do not have the required permissions to view the files attached to this post.

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

Re: Multiple instances in one xpath

Post by odklizec » Thu Mar 07, 2019 10:41 am

Hi,

Well, because there are no usable identification attributes, index number at the end of xpath appears to be the only way? BTW, have you tried GDI Capture approach? This could eventually extract some RAWTexts form your app? And although RAWTests are not perfect, they are definitely better option than indexes ;) I would even consider screenshot-based automation steps, rather than indexes :D
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