Hi
I am having issues with UltraUiaComboBox. Simply i want to select item from dropdown and i do this:
Combobox.SelectedItem = "Item"... After this I see that it clicks on dropdown icon and it is moving from top to bottom of dropdown list and at the end if fails.
What is going on ?
i tried with http://msdn.microsoft.com/en-us/library/system.windows.automation.selectionitempattern.select.aspx
solution and it seams that everything is going to be ok but when it tries to do .select() ... Exception happens.
Chris
Works like a charm :D THANKS A LOT.
BestAlmir
Thanks Chris
I will try this code, and I will let you know is it working for me. For now I added some workaround that is working, but this code would be much more safe.
Best
Almir
Hey Almir,
Try the following code:
public void AssertMethod1() { #region Variable Declarations UltraUiaComboBox uIUltraComboEditor1ComboBox = this.UIForm1Window.UIUltraComboEditor1Window.UIUltraComboEditor1ComboBox; #endregion
AutomationElement comboElement = uIUltraComboEditor1ComboBox.NativeElement as AutomationElement; if (comboElement == null) Assert.Fail("Could not locate the AutomationElement");
ItemContainerPattern containerPattern = comboElement.GetCurrentPattern(ItemContainerPattern.Pattern) as ItemContainerPattern; if (containerPattern == null) Assert.Fail("Could not locate the ItemContainerPattern on the AutomationElement");
AutomationElement selectedElement = containerPattern.FindItemByProperty(null, SelectionItemPatternIdentifiers.IsSelectedProperty, true); if (selectedElement == null) Assert.Fail("No Selected AutomationElement");
// change this line line to match your selected text
Assert.AreEqual("DisplayTextOfSelection", selectedElement.Current.Name); }
At this point, I'd be nervous about us changing the SelectedItem to be the display text of selected item, as it would most likely break existing tests that are expecting it to return the underlying value.
Hi Chris
I am back with questions :)
Could you please help me with this?
I have UltraUiaCombobox with few items. I want to do assert on SelectedItem and when I try that it fails because for SelectedItem it actually selects Value property instead of Text.
And I am asserting by Text value (value that is visible to user).
Its very strange that the options we provided do not work for you. There must be something within the design of your application that we're not aware of. At least you have a workaround that meets your needs. Let us know if you have any other questions.
Chris.