Ashwini M C
Ashwini M C

Reputation: 13

Winapp driver : How to select items from the list using Java

I am trying to automate Windows app using Win app driver, How can we select item from the list using java?

WindowsElement comboBoxElement1=  (WindowsElement) DesktopSession.findElementsByXPath("//List[@Name='Select Outlet:']//*[starts-with(@AutomationId,'listBox')]");
comboBoxElement1.findElementByName("!xyz").click();

I am getting error as not being able to locate the element. Also most of the cases findElementByXpath is not working.

UI looks as below:

enter image description here

Upvotes: 1

Views: 2307

Answers (1)

kishor sharma
kishor sharma

Reputation: 339

use sendkeys:

comboBoxElement1.SendKeys("name of the item");

UPDATE

comboBox.Click(); 
string xPathListItem = $"//Text[contains(@Name, '{dateTom}')]/preceding::Custom[1]/ComboBox/ListItem[1]"; //xPath of your item in combobox
 elem = (WindowsElement)window.FindElementByXPath(xPathListItem);
app.DoubleClick(elem);

here is my DoubleClick method:

public void DoubleClick(WindowsElement elem)
        {
            session.Mouse.MouseMove(elem.Coordinates);
            session.Mouse.DoubleClick(null);
        }

Upvotes: 1

Related Questions