0

I am writing a Unit Test and using FlaUI. I launch an application and then get the main window which is getting the right window but when I try to get a dataGrid from the window it keeps returning null. The code I am using is below:

System.Diagnostics.ProcessStartInfo info = new System.Diagnostics.ProcessStartInfo();
info.FileName = "TEST.exe";
info.Arguments = "Unit_Test";
info.UseShellExecute = false;

Application application = Application.Launch(info);

Window mainWindow = application.GetMainWindow(new UIA3Automation());
cf = new ConditionFactory(new UIA3PropertyLibrary());
var dataGrid = mainWindow.FindFirstDescendant(cf => cf.ByName("squadronGrid")).AsGrid();

Can anyone please help me with this?

  • Just out of curiousity why is this line 'cf = new ConditionFactory(new UIA3PropertyLibrary());' relevant to the example since it is not being used? It just seems suspicious that you happened to use the same name in the lambda expression ( cf ). – adam sranko Jan 18 '23 at 23:42
  • Yes you are right. That line is not needed. But even if I remove it the problem still exists. – Joseph Gabello Jan 19 '23 at 14:06

1 Answers1

0

I found and answer which works. I removed the following line:

cf = new ConditionFactory(new UIA3PropertyLibrary());

and changed cf.ByName to cf.ByAutomationId.

Thanks for your help.