/// <summary> /// Launch the app /// </summary> public static CalculatorAppLfm Launch() { Log.Comment("Launching Calculator and waiting for first page load..."); // Need to set this for the MITALite Tap~ methods to work on high DPI screens. UAPApp.SetTestDPIAwareness(); // We want to be able to see any element in the tree Context.RawContext.Activate(); // Set default wait timeout. MS.Internal.Mita.Foundation.Waiters.Waiter.DefaultTimeout = TimeSpan.FromSeconds(30); // Enable Mita internal logging. MS.Internal.Mita.Foundation.Utilities.Log.OutImplementation = (s, a) => { Log.Comment($"- [MitaLite] { string.Format(s, a) }"); }; using (EtwWaiter appLaunchWaiter = new EtwWaiter(Constants.CalculatorETWProviderGUID, Constants.AppLaunchEndETWEventName)) { var viewDescriptor = NavigationHelper.LaunchApplication(Constants.PackageAppUserModelId); appLaunchWaiter.Wait(TimeSpan.FromSeconds(30)); Window calculatorWindow = new Window(UIObject.Root.Descendants.Find(CoreWindowUICondition)); Debug.Assert(calculatorWindow.ClassName == CoreWindowClassName); // Move our window to the foreground. WindowHelper.SetAsForeground(calculatorWindow.GetTopLevelWindow()); return(new CalculatorAppLfm(new CalculatorAppPom(calculatorWindow), viewDescriptor)); } }
private UIObject LaunchUWPApp(string packageName) { Debug.Assert(_isUWPApp); var nameCondition = UICondition.CreateFromName(packageName); var topLevelWindowCondition = CreateTopLevelWindowCondition().AndWith(nameCondition); return(UAPApp.Launch(_appName, topLevelWindowCondition)); }
private UIObject LaunchNonUWPApp(string packageName) { Debug.Assert(!_isUWPApp); var nameCondition = UICondition.CreateFromName(packageName); var topLevelWindowCondition = UICondition.CreateFromClassName("Window").AndWith(nameCondition); UIObject coreWindow = null; try { coreWindow = UAPApp.Launch(_appName, topLevelWindowCondition); } catch { // UAP.Launch launches the app, but fails trying to find a CoreWindow in the launched app. If the // App is not UWP (as in the case of WPF app hosting a XAML Island), We can fallback to looking for // just a window and use it as the root for future queries. // not a uwp app, see if we can find any window with the condition that matches. coreWindow = FindCore.ByNameAndClassName(root: UIObject.Root, name: packageName, className: "Window", shouldWait: true); } return(coreWindow); }