From ee7b2b25869a109c85c9178612c75356f2afc732 Mon Sep 17 00:00:00 2001 From: Jonathan Finnecy <40675680+jfinnecy@users.noreply.github.com> Date: Mon, 16 May 2022 16:32:17 -0700 Subject: [PATCH 1/3] Create TestURLs.json --- TestURLs.json | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 TestURLs.json diff --git a/TestURLs.json b/TestURLs.json new file mode 100644 index 00000000..3e248ff2 --- /dev/null +++ b/TestURLs.json @@ -0,0 +1,8 @@ +{ + "TestURLs": + [ + "https://apps.powerapps.com/play/{appId}?tenantId={tenantId}&__PATestCaseId={testCaseId}", + "https://apps.powerapps.com/play/{appId}?tenantId={tenantId}&__PATestCaseId={testCaseId}", + "https://apps.powerapps.com/play/{appId}?tenantId={tenantId}&__PATestCaseId={testCaseId}" + ] +} From 2fa016f4e5023bfbde906677c2a5d1eceaafb2b2 Mon Sep 17 00:00:00 2001 From: Jonathan Finnecy Date: Wed, 6 Jul 2022 17:19:42 -0700 Subject: [PATCH 2/3] Update timing of fetching session Id. --- .../Pages/TestAutomation.cs | 41 +++++++++++++++---- 1 file changed, 32 insertions(+), 9 deletions(-) diff --git a/Microsoft.PowerApps.TestAutomation.Api/Pages/TestAutomation.cs b/Microsoft.PowerApps.TestAutomation.Api/Pages/TestAutomation.cs index 62ca7160..35d750c1 100644 --- a/Microsoft.PowerApps.TestAutomation.Api/Pages/TestAutomation.cs +++ b/Microsoft.PowerApps.TestAutomation.Api/Pages/TestAutomation.cs @@ -32,14 +32,16 @@ public BrowserCommandResult ExecuteTestAutomation(Uri uri, int testRunN return this.Execute(GetOptions("Execute Test Automation"), driver => { // Navigate to TestSuite or TestCase URL - var sessionId = InitiateTest(driver, uri); - - Debug.WriteLineIf(sessionId != null, $"Session ID for Test Run #{testRunNumber} is: {sessionId}"); - Debug.WriteLineIf(sessionId == null, $"Session ID for Test Run #{testRunNumber} is NULL"); + InitiateTest(driver, uri); // Check for existence of permissions dialog (1st test load for user) CheckForPermissionDialog(driver); + // Try to report the sessionId. There is a bit of a race condition here, + // so don't do this too close to fullscreen-app-host visibility or it + // will fail to find Core or some other namespace. + TryReportSessionId(driver, testRunNumber); + // Wait for test completion and collect results JObject testResults = WaitForTestResults(driver, maxWaitTimeInSeconds); @@ -129,7 +131,7 @@ internal JObject WaitForTestResults(IWebDriver driver, int maxWaitTimeInSeconds) return jsonResultString; } - internal string InitiateTest(IWebDriver driver, Uri uri) + internal void InitiateTest(IWebDriver driver, Uri uri) { driver.Navigate().GoToUrl(uri); @@ -138,10 +140,14 @@ internal string InitiateTest(IWebDriver driver, Uri uri) // Wait for fullscreen-app-host driver.WaitUntilVisible(By.Id("fullscreen-app-host")); - - string sessionId = (string)driver.ExecuteScript("return Core.Telemetry.Log.sessionId"); - - return sessionId; + if (driver.IsVisible(By.Id("fullscreen-app-host"))) + { + Debug.WriteLine("fullscreen-app-host is visible."); + } + else + { + Debug.WriteLine("fullscreen-app-host is not visible."); + } } public Tuple ReportResultsToDevOps(JObject jObject, int testRunNumber) @@ -224,5 +230,22 @@ public Tuple ReportResultsToDevOps(JObject jObject, int testRunNumber) var countPassFailResult = Tuple.Create(passCount, failCount); return countPassFailResult; } + + private void TryReportSessionId(IWebDriver driver, int testRunNumber) + { + string sessionId; + try + { + sessionId = (string)driver.ExecuteScript("return Core.Telemetry.Log.sessionId"); + } + catch (Exception e) + { + Debug.WriteLine($"Exception getting sessionId: {e.Message}"); + sessionId = null; + } + + Debug.WriteLineIf(sessionId != null, $"Session ID for Test Run #{testRunNumber} is: {sessionId}"); + Debug.WriteLineIf(sessionId == null, $"Session ID for Test Run #{testRunNumber} is NULL"); + } } } \ No newline at end of file From 7f27d51f69095f954bef1565f76a54f3bb345e86 Mon Sep 17 00:00:00 2001 From: Jonathan Finnecy Date: Wed, 6 Jul 2022 17:28:37 -0700 Subject: [PATCH 3/3] Revert "Create TestURLs.json" This reverts commit ee7b2b25869a109c85c9178612c75356f2afc732. --- TestURLs.json | 8 -------- 1 file changed, 8 deletions(-) delete mode 100644 TestURLs.json diff --git a/TestURLs.json b/TestURLs.json deleted file mode 100644 index 3e248ff2..00000000 --- a/TestURLs.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "TestURLs": - [ - "https://apps.powerapps.com/play/{appId}?tenantId={tenantId}&__PATestCaseId={testCaseId}", - "https://apps.powerapps.com/play/{appId}?tenantId={tenantId}&__PATestCaseId={testCaseId}", - "https://apps.powerapps.com/play/{appId}?tenantId={tenantId}&__PATestCaseId={testCaseId}" - ] -}