Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to select an item from ComboBox using WinAppDriver?

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 ?

like image 871
Ankit Rathi Avatar asked Sep 12 '25 11:09

Ankit Rathi


1 Answers

There are two ways to select the items in Combobox dropdown:

  1. 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);
    
  2. 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(); 
    
like image 167
Ankit Rathi Avatar answered Sep 15 '25 00:09

Ankit Rathi