Automating a checklistbox (multicolumn list with tickmarks)

Technology specific object identification, supported applications, web technologies, and 3rd party controls.
conradb
Posts: 19
Joined: Thu Mar 10, 2016 12:00 pm

Automating a checklistbox (multicolumn list with tickmarks)

Post by conradb » Tue Apr 26, 2016 3:19 pm

I have a WPF application (actually an MMC snapin) and need to toggle a listbox item. I'm still very new to the tool, and in the role of a maintainer who is trying to fix a test suite after we made a bunch of UI changes.

Here is my control, struggling to "activate" an item which is offscreen.
ranorex insetui.JPG
ranorex insetui.JPG (18.09 KiB) Viewed 929 times
I uploaded the snapshot to sharefile here : https://citrix.sharefile.com/d-sb536c1db07947b9b

Basically there is a item off the bottom of the visible list which I need to turn on (toggle). I'm keen to do this without writing any user-code. And since my limited experience tells me that the checklistbox customization of the multicolumn lsitbox is pretty common. In fact I'm pretty sure that an multi-column listbox is the same problem kind.

I have once or twice managed to script it so that I am able to "activate" the correct item in the list so that it becomes visible, and then to toggle it, but when I re-run the app, the xpath path I have has not been generalised (shortened) and the tool cannot find the control because it has moved slightly.
pros:Powershell automation guru
cons:UI automation hacker/n00b
Conrad Braam

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

Re: Automating a checklistbox (multicolumn list with tickmarks)

Post by odklizec » Tue Apr 26, 2016 3:59 pm

Hi,

Let's say you want to enable the list item called TestNet-4, which is outside the visible area of list. If you don't insist on using mouse click, for enabling the check box, you can for example use SetValue >> 'Checked' action, which should be able to set the checked state of checkbox, even if the checkbox is outside the visible area of list.

If you insist of using mouse, add Invoke Action >> EnsureVisible() method just before the mouse click action. This should bring the 'invisible' item to visible area of list.

Both actions will require a repo element, with xpath pointing to the checkbox you want to enable (e.g. TestNet-4).

Honestly, the GUI from your snapshot looks rather nasty, with minimum of IDs and therefore a lot of indexes, which can eventually fail, due to future changes in GUI. Here is the xpath I would suggest to try:
/form[@wpfnative='True' and @title='Site Setup' and @processname='mmc']//container[@caption='Network']//container[@caption~'^Select\ one\ or\ more\ networ']//list//text[@caption='TestNet-4'][1]/../../Checkbox
Please notice the index [1] after "text[@caption='TestNet-4'][1]". It's here because there are actually two lists in your GUI, containing the same list items. The truth is, that if the index is not applied, Ranorex will always use the first found element. So you can probably ignore it.

If you wish to 'check' more than just one list item, I would suggest to create a generic repo item with variable (instead of hardcoded list item string 'TestNet-4') and connect this variable to a Test Case data connector, with list of items you want to enable. Then add the recording module responsible for checking list items, to Test Case with data connector. This should allow you to enable multiple items in a loop.

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

conradb
Posts: 19
Joined: Thu Mar 10, 2016 12:00 pm

Re: Automating a checklistbox (multicolumn list with tickmarks)

Post by conradb » Wed Apr 27, 2016 8:56 am

Wow. A lot to take in there, but I expected I need to learn a lot from the answer, and it will take me a long time to digest. Yes the UI does not have many automation IDs, and is rather many controls. UI automation is something completely new to me - I am a API level tester who uses scripts and avoided UI automation like the plague, so automation IDs was something I only started to grasp yesterday. Will ask my developer to add more of these and walk me through the code so I can help myself.

Thanks for quick response. :D
pros:Powershell automation guru
cons:UI automation hacker/n00b
Conrad Braam