0

Given:
Windows 10 Pro Latest
Windows App Driver Latest
Appium extension for Visual Studio 2019 Latest
WPF Application


I have a simple WPF application that just has a combo box on it and I'm just trying to perform a simple test on it. If I use FindElementByClassName method, it works. However, what if there are more than one combo box on the screen? I thought I could use .FindElementByName or .FindElementByAccessibilityId, but these do not work. (Regarding the latter) It does find the combo box element and clicks it but the items appear for a moment and then disappears.

var comboNumber5 = session.FindElementByClassName(nameof(ComboBox));  //This works

vs

var comboNumber5 = session.FindElementByAccessibilityId("combo5"); //Does not work  

Code:

[TestMethod]
public void Combo5Test()
{
    var comboNumber5 = session.FindElementByClassName(nameof(ComboBox));

    comboNumber5.Click();

    var comboNumber5Items = comboNumber5.FindElementsByClassName(nameof(ListBoxItem));

    Assert.IsTrue(comboNumber5Items.Any());
    var lastItem = comboNumber5Items.Last();
    lastItem.Click();

    Assert.AreEqual(comboNumber5.Text, lastItem.Text);

}


Credit: https://github.com/mglodack/WPF-UI-Test-Automation

Rod
  • 14,529
  • 31
  • 118
  • 230

1 Answers1

0

Turns out in my xaml file I wasn't using the x:Name binding. I was just using the Name property.

Rod
  • 14,529
  • 31
  • 118
  • 230
  • Sorry for not showing that code to begin with. I felt it was insignificant. smh. – Rod Apr 22 '20 at 22:50