Generally for web application if we want to select an option from drown we use SelectElement method.
But in Windows application, when I tried to use SelectElement method, I got a below error:
OpenQA.Selenium.Support.UI.UnexpectedTagNameException: Element should have been select but was ControlType.ComboBox
So for windows application, How to select a item from ComboBox dropdown ?
There are two ways to select the items in Combobox dropdown:
By Using Keyboard keys if elements don't have unique attribute and value:
WindowsElement comboBoxElement = session.FindElementByClassName("ComboBox");
comboBoxElement.Click();
comboBoxElement.SendKeys(Keys.Down);
comboBoxElement.SendKeys(Keys.Enter);
By using drop down list Element if it has unique attribute and value:
WindowsElement comboBoxElement = session.FindElementByClassName("ComboBox");
comboBoxElement.Click();
comboBoxElement.FindElementByAccessibilityId("Light Dismiss").Click();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With