select by text(with regex) for list items

Ask general questions here.
rsudhak
Posts: 32
Joined: Fri Jan 04, 2019 1:38 pm

select by text(with regex) for list items

Post by rsudhak » Thu Jan 24, 2019 3:09 am

Hi ,

I have a comboBox, which when clicked opens up a pop up box(container) with listitem. All I need is to select an item based on the text .

when I use spy, I cant see the popup(container) in it. When I record as a new solution , that's where I come to know that there is a pop up box involved.

Combobox = //combobox[@automationid='CableTypeComboBox']

Popup = /form[@classname='Popup' and @orientation='None' and @processname='ProDesign']

items in the list =container/listitem[1]/text[@name~'^Single-core,\ 70°C\ thermop']
container/listitem[4]/text[@name~'^Multicore,\ 70°C\ thermopla']

I need to select item from the list which has text with space and new line I guess (need regex) not sure as name or text attribute
eg Multicore, 70°C thermoplastic insulated/sheathed, non-arm
Cu Flexible
Attached snapshot as well as screenshot of the recorded repo which has popup box paths and details
Attachments
RepoUpOneLevel.rxsnp
parent level repo from spy
(78.69 KiB) Downloaded 1 time
combobox.rxsnp
combo box and child elements from spy
(64.14 KiB) Downloaded 1 time
RecordedRepo.PNG
when recorded, this is how the repository looks in ranorex
RecordedRepo.PNG (21.49 KiB) Viewed 88 times

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

Re: select by text(with regex) for list items

Post by odklizec » Thu Jan 24, 2019 9:13 am

Hi,

At first, both snapshots show technology limitation warning, about accessing WPF elements using UIA. Please switch to WPF native, which offers much more details.

At next, neither snapshot shows the popup in question. Please use instant tracking to create snapshot of the popup, eventually, create snapshot directly from recording.
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

rsudhak
Posts: 32
Joined: Fri Jan 04, 2019 1:38 pm

Re: select by text(with regex) for list items

Post by rsudhak » Thu Jan 24, 2019 9:16 am

fairly new to Ranorex, how do I instant track elements, and how do I create snapshot from recorded elements

rsudhak
Posts: 32
Joined: Fri Jan 04, 2019 1:38 pm

Re: select by text(with regex) for list items

Post by rsudhak » Thu Jan 24, 2019 9:22 am

Tried Instant tracking, but looks like my system goes crazy, how to untrack it , because its getting repo element for all my clicks

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

Re: select by text(with regex) for list items

Post by odklizec » Thu Jan 24, 2019 9:45 am

Instant tracking should be finished once the shortcut is released? But I remember such issue with an older versions of Ranorex, but I see you are using 8.3.1m which is only one version below most recent version? Try to click inside the UI, eventually, try to press and hold F12, which should pause tracking. Then try to kill Spy ;)

To create a snapshot via Recording, simply add Create Snapshot action to the recording of your choice. The action should point to the popup element, from which you would like to create the snapshot.
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

rsudhak
Posts: 32
Joined: Fri Jan 04, 2019 1:38 pm

Re: select by text(with regex) for list items

Post by rsudhak » Thu Jan 24, 2019 9:53 am

Strangely didn't seem to work...looks like spy + instant tracking goes on an infinite loop.

Have attached another snapshot of the whole element with WPFPreferred set.

When done instant tracking, the element that got recorded in the repo was SomeContextMenu, screenshot attached.... how do I take snapshot from renorex solution?
Attachments
repo.PNG
repo.PNG (23.15 KiB) Viewed 76 times
MainRepo.rxsnp
(73.68 KiB) Downloaded 2 times

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

Re: select by text(with regex) for list items

Post by odklizec » Thu Jan 24, 2019 10:05 am

I'm afraid, the snapshot still complains about UIA. Please try to set the WPF plugin to WPFPreferred and start the Spy as Administrator. Unfortunately, the snapshot still does not contain the popup.

To create a snapshot of popup from Recording, you must manually add Create Snapshot action to recording (right after click on combobox, which opens the popup) and it should point to Popup or SomeContextMenu repo element. Then simply run the project and post snapshot created by test.
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

rsudhak
Posts: 32
Joined: Fri Jan 04, 2019 1:38 pm

Re: select by text(with regex) for list items

Post by rsudhak » Thu Jan 24, 2019 12:08 pm

Hopefully got the wpf snapshot this time.. Attached
Attachments
wpf_Snapshot.rxsnp
(2.07 MiB) Downloaded 3 times

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

Re: select by text(with regex) for list items

Post by odklizec » Thu Jan 24, 2019 12:14 pm

Hi,

OK, no instrumentation error now ;) So now we have a snapshot of the app, but still no snapshot of the popoup/container, with the list of items (displayed after clicking combobox). Could you please create/post such snapshot? If Instant Tracking is failing for you, you need to use Create Snapshot action in recording, as I described above. Thanks.
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

rsudhak
Posts: 32
Joined: Fri Jan 04, 2019 1:38 pm

Re: select by text(with regex) for list items

Post by rsudhak » Thu Jan 24, 2019 12:16 pm

The snapshot should have it....


this is the pop up that I am talking about : /form[@wpfnative='True' and @title='Cable Settings' and @processname='ProDesign']/container[@automationid='Main']//container[@automationid='ComponentSettingsView']//element[@automationid='PageContentControl']//container[@automationid='CableTypeViewElement']/?/?/combobox[@automationid='CableTypeComboBox']/container[@automationid='MainGrid']/contextmenu[@automationid='Popup']

And this is the container which has the listItems
/form[@wpfnative='True' and @title='Cable Settings' and @processname='ProDesign']/container[@automationid='Main']//container[@automationid='ComponentSettingsView']//container[@automationid='CableTypeViewElement']/?/?/combobox[@automationid='CableTypeComboBox']/container[@automationid='MainGrid']/contextmenu[@automationid='Popup']/container[@automationid='DropDown']/container[2]

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

Re: select by text(with regex) for list items

Post by odklizec » Thu Jan 24, 2019 12:48 pm

Ahhh I see now! It's hidden in combobox structure ;) But I guess that when the combo box is expanded, the container is displayed outside the application root, as a standalone popup/container element?

Anyway, the problem of the list items is, that they are displayed in multiple text elements. So simple regex will not work here.

Here is an example of xpath, that should be close to what you want. You just need to create two variables and fill them with expected text (one for each line).
/form[@processname='ProDesign' and @class='HwndWrapper[ProDesign.exe;;308ab6c1-7bb0-4c8c-add9-c0548820cc60]']/container[@automationid='Main']//container[@automationid='ComponentSettingsView']//element[@automationid='PageContentControl']//container[@automationid='CableTypeViewElement']/?/?/combobox[@automationid='CableTypeComboBox']/container[@automationid='MainGrid']/contextmenu[@automationid='Popup']/container[@automationid='DropDown']/?/?/listitem/?/?/text/element[@text='Single-core, 70°C thermoplastic non-arm']/parent::text/element[@text='Cu Table 4D1']
However, with the snapshot you provided, it returns two elements, because the list seems to be doubled? So you must also specify in the xpath, which one is the right one? And as mentioned, I'm suspecting, that after expanding combo box, the popoup with the list of items will be shown as a separate element, so the xpath would most probably need some further changes e.g. like this:

Code: Select all

/contextmenu[@automationid='Popup']/container[@automationid='DropDown']/?/?/listitem/?/?/text/element[@text='Single-core, 70°C thermoplastic non-arm']/parent::text/element[@text='Cu Table 4D1']

or like this:

Code: Select all

/contextmenu[@automationid='Popup' and @processname='ProDesign']/container[@automationid='DropDown']/?/?/listitem/?/?/text/element[@text='Single-core, 70°C thermoplastic non-arm']/parent::text/element[@text='Cu Table 4D1']
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

rsudhak
Posts: 32
Joined: Fri Jan 04, 2019 1:38 pm

Re: select by text(with regex) for list items

Post by rsudhak » Fri Jan 25, 2019 11:33 am

Tried various combinations but doesn't seem working, its not at all picking from the list .
Get No element found for path

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

Re: select by text(with regex) for list items

Post by odklizec » Fri Jan 25, 2019 12:01 pm

Hi,

I think the problem is in the way the popup window is created outside the main application window, as a separate element. Please create snapshot of the popup window, as I suggested in previous posts (from recording). This would help me or anyone else here to adapt the xpath to correct one.
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