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

Milo
  • 3,365
  • 9
  • 30
  • 44

1 Answers1

1

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);
        }
kishor sharma
  • 179
  • 2
  • 17
  • Thank you Kishore. I tried with SendKeys, its not able to find the element. – Ashwini M C Oct 15 '19 at 10:34
  • To be honest, it works sometime. and sometime it doesn't. Even I had implemented different strategy. I will update my answer with what I had implemented. – kishor sharma Oct 18 '19 at 03:24
  • Hi @AshwiniMC if my answer helps you, will you please mark it as answered. In this way, other member will directly go for the accepted answers. – kishor sharma Nov 14 '19 at 01:35