diff --git a/src/Microsoft.PowerApps.TestEngine/SingleTestRunner.cs b/src/Microsoft.PowerApps.TestEngine/SingleTestRunner.cs index cb5e8ae4f..94cded844 100644 --- a/src/Microsoft.PowerApps.TestEngine/SingleTestRunner.cs +++ b/src/Microsoft.PowerApps.TestEngine/SingleTestRunner.cs @@ -116,7 +116,11 @@ public async Task RunTestAsync(string testRunId, string testRunDirectory, TestSu Logger.LogInformation("Successfully navigated to target URL"); // Log in user - await _userManager.LoginAsUserAsync(desiredUrl); + // await _userManager.LoginAsUserAsync(desiredUrl); + + // IF USING "LOCAL USER MANUAL LOGIN", THEN CONSIDER + // WAITING HERE FOR THE USER TO LOG IN & REDIRECT + // BACK TO THE APP // Set up network request mocking if any await _testInfraFunctions.SetupNetworkRequestMockAsync(); diff --git a/src/Microsoft.PowerApps.TestEngine/TestInfra/PlaywrightTestInfraFunctions.cs b/src/Microsoft.PowerApps.TestEngine/TestInfra/PlaywrightTestInfraFunctions.cs index 55f0f6ba7..461cc6c21 100644 --- a/src/Microsoft.PowerApps.TestEngine/TestInfra/PlaywrightTestInfraFunctions.cs +++ b/src/Microsoft.PowerApps.TestEngine/TestInfra/PlaywrightTestInfraFunctions.cs @@ -70,12 +70,23 @@ public async Task SetupAsync() throw new InvalidOperationException(); } - var launchOptions = new BrowserTypeLaunchOptions() + var launchOptions = new BrowserTypeLaunchPersistentContextOptions() { Headless = testSettings.Headless, - Timeout = testSettings.Timeout + Timeout = testSettings.Timeout, + Channel = "msedge", + ViewportSize = new ViewportSize() + { + Width = browserConfig.ScreenWidth ?? 800, + Height = browserConfig.ScreenHeight ?? 600 + } }; + if (testSettings.RecordVideo) + { + launchOptions.RecordVideoDir = _singleTestInstanceState.GetTestResultsDirectory(); + } + var browser = PlaywrightObject[browserConfig.Browser]; if (browser == null) { @@ -83,31 +94,9 @@ public async Task SetupAsync() throw new InvalidOperationException("Browser not supported."); } - Browser = await browser.LaunchAsync(launchOptions); - _singleTestInstanceState.GetLogger().LogInformation("Browser setup finished"); - - var contextOptions = new BrowserNewContextOptions(); - - if (!string.IsNullOrEmpty(browserConfig.Device)) - { - contextOptions = PlaywrightObject.Devices[browserConfig.Device]; - } - - if (testSettings.RecordVideo) - { - contextOptions.RecordVideoDir = _singleTestInstanceState.GetTestResultsDirectory(); - } - - if (browserConfig.ScreenWidth != null && browserConfig.ScreenHeight != null) - { - contextOptions.ViewportSize = new ViewportSize() - { - Width = browserConfig.ScreenWidth.Value, - Height = browserConfig.ScreenHeight.Value - }; - } + BrowserContext = await browser.LaunchPersistentContextAsync(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), launchOptions); + Browser = BrowserContext.Browser; - BrowserContext = await Browser.NewContextAsync(contextOptions); _singleTestInstanceState.GetLogger().LogInformation("Browser context created"); } @@ -206,7 +195,7 @@ public async Task GoToUrlAsync(string url) } // TODO: consider whether to make waiting for network idle state part of the function input - var response = await Page.GotoAsync(url, new PageGotoOptions() { WaitUntil = WaitUntilState.NetworkIdle }); + var response = await Page.GotoAsync(url, new PageGotoOptions() { WaitUntil = WaitUntilState.Load }); // The response might be null because "The method either throws an error or returns a main resource response. // The only exceptions are navigation to about:blank or navigation to the same URL with a different hash, which would succeed and return null." diff --git a/src/PowerAppsTestEngine/PowerAppsTestEngine.csproj b/src/PowerAppsTestEngine/PowerAppsTestEngine.csproj index 6877d58d6..6ce4f737f 100644 --- a/src/PowerAppsTestEngine/PowerAppsTestEngine.csproj +++ b/src/PowerAppsTestEngine/PowerAppsTestEngine.csproj @@ -20,6 +20,9 @@ + + PreserveNewest + PreserveNewest