'In desktop automation ,how to call a var having GETMAinWindow response in another method?

I am trying to automate Outlook using FLAui with C#. I have made a commom function that gets the main window details. How can I call it to use in another method? My code looks something like:

var window = app.GetMainWindow(automation); // var automation launches outlook
                ConditionFactory cf = new ConditionFactory(new UIA3PropertyLibrary());
                var button1 = window.FindFirstDescendant(cf1 => cf.ByText("New mail"))?.AsButton();

Now this is my commonTest method How can I use this Var window in another method?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source