Page 1 of 1

select by text(with regex) for list items

Posted: Thu Jan 24, 2019 3:09 am
by rsudhak
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

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

Posted: Thu Jan 24, 2019 9:13 am
by odklizec
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.

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

Posted: Thu Jan 24, 2019 9:16 am
by rsudhak
fairly new to Ranorex, how do I instant track elements, and how do I create snapshot from recorded elements

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

Posted: Thu Jan 24, 2019 9:22 am
by rsudhak
Tried Instant tracking, but looks like my system goes crazy, how to untrack it , because its getting repo element for all my clicks

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

Posted: Thu Jan 24, 2019 9:45 am
by odklizec
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.

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

Posted: Thu Jan 24, 2019 9:53 am
by rsudhak
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?

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

Posted: Thu Jan 24, 2019 10:05 am
by odklizec
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.

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

Posted: Thu Jan 24, 2019 12:08 pm
by rsudhak
Hopefully got the wpf snapshot this time.. Attached

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

Posted: Thu Jan 24, 2019 12:14 pm
by odklizec
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.

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

Posted: Thu Jan 24, 2019 12:16 pm
by rsudhak
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]

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

Posted: Thu Jan 24, 2019 12:48 pm
by odklizec
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']

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

Posted: Fri Jan 25, 2019 11:33 am
by rsudhak
Tried various combinations but doesn't seem working, its not at all picking from the list .
Get No element found for path

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

Posted: Fri Jan 25, 2019 12:01 pm
by odklizec
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.