Is there a way to get the values from a WPFComboBox

Nov 5, 2008 at 10:58 PM
I have some code that selects a value from a WPFComboBox, but after that I want to retrieve the name of the value I select so that I can use it further down in my tests.

Here is the code I use to select the value:

 

var searchCriteria = SearchCriteria.ByAutomationId("RequestTypeComboBox");
var RequestType = Environment.window.Get<WPFComboBox>(searchCriteria);
RequestType.Click();
RequestType.Items[0].Click();


Using UISpy the attribute I want to get is the "Name".  Does anybody know how to do this?

I've already tried using:
RequestType.Items[0].Id
RequestType.Items[0].PrimaryIdentification
RequestType.Items[0].Name
RequestType.Items[0].Text

But those aren't returning the value I'm looking for.

Thanks in advance.

 

Nov 5, 2008 at 11:20 PM
Have you tried RequestType.SelectedItem or RequestType.SelectedItemText ?
Nov 6, 2008 at 7:44 PM
Thanks for the response.  I did try that but it gives me the object name, not the name of the value that was selected.
Coordinator
Nov 9, 2008 at 10:47 AM
This is a known issue in white because of UIA bug.
This happens when ComboBox items in the actual code do not have implementation of ToString method which provides the Text displayed.
Coordinator
Nov 9, 2008 at 10:48 AM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.