Search Item in a list and select

Best practices, code snippets for common functionality, examples, and guidelines.
FrancisMoreau
Posts: 3
Joined: Fri Jul 24, 2020 9:12 am

Search Item in a list and select

Post by FrancisMoreau » Fri Jul 24, 2020 9:40 am

Hi,
I'm a new user of Ranorex and I'm stuck on a multi-column list problem.
On a web page, I have to look for a value in the "Name" column and then click on an icon in the "Action" column
Image

I've searched the different tutorials and courses but I couldn't find anything..

Thank you for your help

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

Re: Search Item in a list and select

Post by Support Team » Mon Jul 27, 2020 6:13 pm

Hi Francis,

With a Ranorex Snapshot file, I can provide better example RxPaths, but in the meantime, I can use this test webpage (click "Load" to show the example table).

To achieve this, you want your RxPath to point to the "Name" cell, then back up to the row using /../ (parent), then down to the "Action" cell.

1. Point to "Name" cell:

Code: Select all

/dom[@domain='www.ranorex.com']//table[#'VIPs']//td[@innertext='Marie']
2. Navigate to parent row element using /../

Code: Select all

/dom[@domain='www.ranorex.com']//table[#'VIPs']//td[@innertext='Marie']/../
3. Navigate to child "Action" cell (5th column in this example). This is the final RxPath to use in the test. Changing "Marie" to another name will show the proper category in the row with this name.

Code: Select all

/dom[@domain='www.ranorex.com']//table[#'VIPs']//td[@innertext='Marie']/../td[5]
You should be able to apply this same method to your table. if you have any trouble with it, provide a Ranorex Snapshot file if this table and I will be happy to further assist.

Cheers,
Ned
.
Image

FrancisMoreau
Posts: 3
Joined: Fri Jul 24, 2020 9:12 am

Re: Search Item in a list and select

Post by FrancisMoreau » Thu Jul 30, 2020 11:06 am

Thank you for your help,

here is the snapshot
SelectOLTDetail.rxsnp
(282.14 KiB) Downloaded 5 times
The structure of the table is a bit complicated I don't see how to go from the name to the action

FrancisMoreau
Posts: 3
Joined: Fri Jul 24, 2020 9:12 am

Re: Search Item in a list and select

Post by FrancisMoreau » Thu Aug 06, 2020 8:37 am

Support Team wrote:
Mon Jul 27, 2020 6:13 pm
You should be able to apply this same method to your table. if you have any trouble with it, provide a Ranorex Snapshot file if this table and I will be happy to further assist.
Hi Support team,
Have you been able to examine my problem?
I'm still stuck.

Thank you for your help.

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

Re: Search Item in a list and select

Post by odklizec » Thu Aug 06, 2020 9:24 am

Hi,

The UI you are working with is somewhat complicated and there is not an easy way to achieve what you want. You must create at very least two xpaths and obtain ChildIndex of row, belonging to item you want to edit and then use this ChildIndex (representing row number) in second xpath (repo element), which finds the 'view' or 'remove' button (you need to create two repo elements, if you want to click both buttons) .

This xpath returns row, to which belongs the item name "78vzy1-gp-01" (of course, you should replace the hardcoded name with variable connected to data connector). Then using GetValue action, obtain the ChildIndex attribute of the row and store it in variable...
/dom[@domain='10.66.1.116:8080']//div[#'uxfwk-rm-coreEquipment-list-table']/?/?/div//table/tbody/tr/td[@class~'col-name']//div/span[@innertext='78vzy1-gp-01']/ancestor::tr
Now you need to apply the obtained ChildIndex value in below xpath, which returns either 'view' or 'remove' icon belonging to item you want to edit...
/dom[@domain='10.66.1.116:8080']//div[#'uxfwk-rm-coreEquipment-list-table']//div[@class~'col-last']/div[@class~'contents']/table/tbody/tr[@childindex=$obtainedChildIndexVal]//div[@class='ng-scope']//ul/li[@name='view']

/dom[@domain='10.66.1.116:8080']//div[#'uxfwk-rm-coreEquipment-list-table']//div[@class~'col-last']/div[@class~'contents']/table/tbody/tr[@childindex=$obtainedChildIndexVal]//div[@class='ng-scope']//ul/li[@name='remove']
Hope this helps?
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