'Appium/WPF: access selected combo box item

I'm getting the WPF combo box, where the automation id is set to "MyComboBox", by using the following:

var myComboBox = OpenQA.Selenium.Windows.WindowsElement.FindElementById("MyComboBox")

Selecting an item in the combo box is done by this:

 myComboBox.SendKeys("MyItem 1")

I haven't found a way to get the list of items from the combo box or even the selected item to check if it is really selected.

Any hints would be appreciated on how to get the selected item and the list of items in the combo box using Appium.



Solution 1:[1]

What you could do is assign an item count to the items then declare the count as int Count; then in the method that calls the item or the method that adds the item to the list then add the "Count++" to auto increment the time to add one to the count which would be used as an id for the time in the combo box.

If you would like to add the item every time to an array or list then remember to initialize the count at the first instance to -1.

This is so that when the first digit is added to the array the count start at item number 0 this will be the first position of the arrays.

The first item stored into the combo box will be in the item position number 0.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Thaveshan Naidoo