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.
if this is not possible to do, is there any other way to get all items except combobox.items.
I made workaround to select dropdown item but this combobox.items method is taking long time to get all the items.
I am trying to get all items using NativeElements ..
Thanks to good friend Chris :) who pointed me in right direction i made workaround that looks like this:
UltraUiaComboBox uuComboBox = ( UltraUiaComboBox )control;
if ( uuComboBox.SelectedItem == providedValue) break;
AutomationElement containerAutomationElement = uuComboBox.NativeElement as AutomationElement; AutomationElementCollection elements = containerAutomationElement.FindAll( TreeScope.Children, Condition.TrueCondition ); uuComboBox.SetFocus(); Keyboard.SendKeys( "{HOME}" );
for ( int i = 0; i < elements.Count; i++ ) { try { string name = elements[ i ].Current.Name; if ( String.IsNullOrEmpty( name ) || name != providedValue) Keyboard.SendKeys( "{DOWN}" ); else break; } catch { } }
I know that this is not best solution but it is only one that works for me now. If someone finds other solution please reply on this thread.
Hello,
Once you have an instance to UltraUiaComboBox (UltraUiaComboBox combox = this.UIForm1Window.UIUltraComboEditor1Window.UIUltraComboEditor1ComboBox;), you could use EditableItem property in order to select need item ( combox.EditableItem = "Item9";).
I hope that this will helps you.
nope :)
this is not working for me. Thanks however.
Hello ,
I have tested this issue with Infragistics 13.1 SR 2048. In the attached zip you will find the sample and small video of my test. So maybe you are using some older version.
Please let me know if you need my further assistance on this matter.
Hi Hristo
Thanks for explanation and attachment. I appreciate it.
Yes it is true, currently we are using 12.2 version and it will stay like that for a while.
so i will stick to my solution for now.
thanks
Almir
Hello Amir,
Thank you for your feedback.
Thank you for using Infragistics Components.
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
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.