This project is read-only.

WPFComboxBox showing strange behavior for me

Nov 11, 2011 at 2:55 PM

It is quite well possible that I am just simply not familiar enough with how WPF works under the hood to understand why this behavior is as it is. I am writing some UI Automation code using White on this window I have that includes a WPFComboBox without a name, so I had to grab it by index from the Window's Items list. Also, why it is identifying it as a WPFComboBox is interesting because while I realize that a WPFComboBox includes the behavior of a drop down list, I am pretty sure this UI item is just a drop down list and not a combo box.

Anyways, there are two options in this list, let's say item1 and item2. The default is set to item1 but I need to select item2. So I tried the Select method on the WPFComboBox. It didn't work. I tried the Click() method on the WPFComboBox followed by a call of the Click() method for the WPFListItem. That didn't work either. Last, I tried the same as the last attempt but I placed a sleep() call for 0.1 seconds in case the small animation time that was needed for the drop down menu to full expand was getting in the way. That worked! However, I am somewhat confused as to why the Select() call didn't work. I mean, it didn't throw an error, but it looked like it just tried to make the same actions as my second attempt because both times the cursor correctly identified the WPFComboBox and went over to it but it did not extend the menu and/or select item2. I just always ended up with a cursor hovering over the WPFComboBox with item1 still selected. Just in case I was using the Select() method wrong compared to the intention of the method, I called it on the WPFListItem itself, but that just resulted in the cursor clicking on whatever was in the furthest upper-left hand corner.

Also, whenever I tried saving the WPFIListItem to a variable to then pass to another function, it would never work because it would say it doesn't exist anymore. This confused me at first, but then I noticed when I first opened the program and then the window, if I didn't click the drop down menu yet but found the WPFComboBox instance representing it and checked its Items attribute, it was empty. But once I had clicked the drop down menu button, the Items attribute was populated. However, every time I asked it to print the instances in Items, they would always be located at new memory addresses as if they were always new instances every time I called it.

So can someone tell me why this behavior is acting as such, and what would be a simpler way to select the choice I want?

Nov 15, 2011 at 2:43 PM


first of all, ComboBox behaviour is strange in my eyes too. :)

So 1. in older Versions of White all ComboBox will be openend if you use the Get Operation.

in new version you can define this in the appconfig

So the elements of the ComboBox will be known

If you have a look at UIAVerify or UISpy and the correct realiziation than you will see the drop down is only another window with elements and these elements only exists if the window is visible.


i implement an extension that :


click the combobox,

gets all elements

gets the needed element

opens again (if needed)

and select the ListItem


all with short timeouts, you can also use a while (!item.Visible) to wait if all elements always shown in drop down.


Last to say that the comboxBox support need some imporvement here





Nov 16, 2011 at 2:26 PM
Edited Nov 16, 2011 at 2:27 PM

Thanks for the information. I saw in a few places, including in the functional testing with White project power presentation I think, the appconfig being mentioned, but I can't seem to find the documentation for it and how to use it.

Then again, I am pretty sure I have white set up in a completely unorthodox manner.

White seemed like the best UI automation tool with WPF support for my project but White is in C# (which I don't know, but seemed similar enough to Java) and my project for work is in Python.

So I just ported my project to run on IronPython, downloaded White, dropped the White assemblies into IronPython's DLL folder, and it worked.

However, due to this setup, it complains about Log4Net not being configured and looking for a local log4net.config file.

Anywho, long story short, any way I could get a link to some info on how to setup that appconfig data?



Nov 16, 2011 at 2:55 PM

Have a look here


look for "ComboBoxItemsPopulatedWithoutDropDownOpen"