Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 32 additions & 9 deletions Microsoft.PowerApps.TestAutomation.Api/Pages/TestAutomation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,16 @@ public BrowserCommandResult<JObject> 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);

Expand Down Expand Up @@ -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);

Expand All @@ -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<int, int> ReportResultsToDevOps(JObject jObject, int testRunNumber)
Expand Down Expand Up @@ -224,5 +230,22 @@ public Tuple<int, int> 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");
}
}
}