how to identify rawtext based of another rawtext

Ask general questions here.
User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 3921
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

how to identify rawtext based of another rawtext

Post by odklizec » Fri Feb 07, 2014 1:41 pm

Hi folks,

I have a SysTreeView with some rawtext elements. I want to identify a rawtext element (just row, column is fixed) based of a column/row coordinates of another rawtext. Unfortunately, Ranorex currently does not support SysTreeView with multiple columns, so I'm forced to use rawtext for element identification.

The element I want to identify has a variable content so this is why I cannot use rawtext for its identification. However, there is a neighbor element, with fixed text, so I think it would be an ideal starting element for identification of element in question. Sadly, I cannot find a way how to configure xpath to identify my problematic element. Here is a screenshot:
Raw_row.png
Raw_row.png (240 KiB) Viewed 993 times
And here is snapshot:
SysTreeView.rxsnp
(97.31 KiB) Downloaded 95 times
I can easily identify "Volume" RawText. The problem with neighboring cell is that its row is always -1 of the "Volume" row. Column is not a problem as I know it will always be 6. Any idea how to identify that "variable" cell using xpath?
Last edited by odklizec on Mon Feb 10, 2014 5:22 pm, edited 1 time in total.
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

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: how to identify rawtext based of another rawtext

Post by Support Team » Mon Feb 10, 2014 3:36 pm

Hi odklizec,

Unfortunately you forgot to attach the Ranorex snapshot and we are not exactly sure which cell you want to access. Please give more details concerning your issue.

Regards,
Robert
.
Image

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

Re: how to identify rawtext based of another rawtext

Post by odklizec » Mon Feb 10, 2014 5:24 pm

Hi Robert,

Thank you for the reply! Silly me ;) Snapshot is now available.
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

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: how to identify rawtext based of another rawtext

Post by Support Team » Thu Feb 13, 2014 2:50 pm

Hi,

Thanks, now it works!
In order to get the “neighbor” element of “Volume” you can use either:

Code: Select all

//tree[@class='SysTreeView32']//following-sibling::rawtext[][1]
Or

Code: Select all

//tree[@class='SysTreeView32']//following-sibling::rawtext[@row='2']
Or

Code: Select all

/form[@title='LiteBox3D']//rawtext[@rawtext~'.*mm3']
But the last solution is just suitable, if there is only one “mm3” field within your application so I would rather use the first or second solution.

Regards,
Robert
.
Image

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

Re: how to identify rawtext based of another rawtext

Post by odklizec » Fri Feb 14, 2014 4:49 pm

Hi Robert,

Thanks for the reply. Unfortunately, neither solution is what I'm exactly looking for ;)

The problem of the first solution is, that it rely on exact index number of volume value rawtext. So if the index changes, the path may return wrong rawtext.

The second solution, using the row index, is very close. Unfortunately, as I mentioned above, I cannot be sure the row index is always the same. It may change during the systree manipulation. The only thing I'm quite sure is, that the Volume value rawtext (0mm3) row is "Volume" RawText row-1 and column is "Volume" RawText column+1

In other words, if the "Volume" rawtext Column=5 and Row=3 then the Volume value rawtext Column=6 and Row=2.

So I hoped to be able to identify the Volume "value" col/row based of the "Volume" rawtext col/row.
e.g. //tree[@class='SysTreeView32']/rawtext[@rawtext='Volume']what-to-put-here-to-identify-volume-value-col-row

So far, it looks the third solution is the best one, sadly, it's good just for mm3 and mm2 but not for the last row, which contains combined text. But maybe I can somehow use regexp to identify that last rawtext?
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

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: how to identify rawtext based of another rawtext

Post by Support Team » Mon Feb 17, 2014 9:53 am

Hi,
In order to get the desired element please use following code sequence:
RawText a = "//tree[@class='SysTreeView32']/rawtext[@rawtext='Volume']";
         rowHelper = a.Row;
         rowHelper -= 1;
         columnHelper = a.Column;
         columnHelper  += 1
         RawText b = @"//tree[@class='SysTreeView32']/rawtext[@column='" + columnHelper + "' and @row='" +rowHelper +"']";
The row index is decremented by one and the column is incremented by one starting from the “Volume”-element.

Regards,
Robert
.
Image

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

Re: how to identify rawtext based of another rawtext

Post by odklizec » Mon Feb 17, 2014 5:10 pm

Hi,

Thanks for the code sample! I somewhat hoped there is a way to solve my problem using the repository (to be able to test the cells with spy), but I can live without it. Your solution seems to be perfect for playback identification and that's all I really need ;) Thanks again!
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