TestStack / White

DEPRECATED - no longer actively maintained
Other
1.02k stars 487 forks source link

Get<ListView> (ByAutomationId(...)) does not work, but GetElement(ByAutomationId(...)) does. #576

Closed mwbowers closed 7 years ago

mwbowers commented 7 years ago

I'm working on moving my project from Visual Studio 2015 to Visual Studio 2017 to test our Visual Studio extensions. Previously, I used the line:

var rows = newProjectWindow.Get<ListView>(ByAutomationId("lvw_Extensions")).Rows.GetEnumerator();

which worked to get the list of project templates in the new project window.

This no longer works in 2017.

Initially, I thought maybe the AutomationId had changed, but verified that it had not.

I was able to get the AutomationElement for the List View using:

var listViewAe = newProjectWindow.GetElement(ByAutomationId("lvw_Extensions"));

According to Issue #418, it looks like I should use Get rather than GetElement, so I tried:

var listView = newProjectWindow.Get<ListView>(ByAutomationId("lvw_Extensions"));

which also did not work.

Any guidance would be appreciated. Thank you.

mwbowers commented 7 years ago

Update:

When using Visual UI Automation Verify, the automation element in Visual Studio 2015 is a DataGrid with DataItems:

vs2015

And in 2017, it is now a ListView with ListItems:

image

So, changed it to ListBox rather than ListView, and it works.