1

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

4

1 回答 1

1

使用发送键:

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

更新

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);

这是我的 DoubleClick 方法:

public void DoubleClick(WindowsElement elem)
        {
            session.Mouse.MouseMove(elem.Coordinates);
            session.Mouse.DoubleClick(null);
        }
于 2019-10-15T06:38:49.790 回答