'Running Power Platform / Selenium automated tests on build agent gives error "session not created"

We are investigating executing Power Platform automated tests in our Azure DevOps pipeline.

The tests run and pass successfully when we run them from within a Power Platform session.

However, when we run them in a pipeline (meaning they get executed on a Windows Build Agent that we've created) we get the error below.

The framework uses Selenium as part of the test execution stack.

Has anyone else experienced this and resolved it?

  Error Message:
   Test method Microsoft.PowerApps.TestAutomation.Tests.TestAutomation.RunTestAutomation threw exception: 
System.InvalidOperationException: session not created
from disconnected: Unable to receive message from renderer
  (Session info: chrome=99.0.4844.51) (SessionNotCreated)
  Stack Trace:
      at OpenQA.Selenium.Remote.RemoteWebDriver.UnpackAndThrowOnError(Response errorResponse)
   at OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String driverCommandToExecute, Dictionary`2 parameters)
   at OpenQA.Selenium.Remote.RemoteWebDriver.StartSession(ICapabilities desiredCapabilities)
   at OpenQA.Selenium.Remote.RemoteWebDriver..ctor(ICommandExecutor commandExecutor, ICapabilities desiredCapabilities)
   at OpenQA.Selenium.Chrome.ChromeDriver..ctor(ChromeDriverService service, ChromeOptions options, TimeSpan commandTimeout)
   at Microsoft.PowerApps.TestAutomation.Browser.BrowserDriverFactory.CreateWebDriver(BrowserOptions options) in C:\agent\_work\4\s\test\sdk\PowerAppsTestAutomation\Microsoft.PowerApps.TestAutomation.Browser\BrowserDriverFactory.cs:line 25
   at Microsoft.PowerApps.TestAutomation.Browser.InteractiveBrowser.get_Driver() in C:\agent\_work\4\s\test\sdk\PowerAppsTestAutomation\Microsoft.PowerApps.TestAutomation.Browser\InteractiveBrowser.cs:line 85
   at Microsoft.PowerApps.TestAutomation.Browser.BrowserPage.Execute[TResult](BrowserCommandOptions options, Func`2 delegate) in C:\agent\_work\4\s\test\sdk\PowerAppsTestAutomation\Microsoft.PowerApps.TestAutomation.Browser\BrowserPage.cs:line 182
   at Microsoft.PowerApps.TestAutomation.Api.TestAutomation.GetTestURLs(String filePath) in C:\agent\_work\4\s\test\sdk\PowerAppsTestAutomation\Microsoft.PowerApps.TestAutomation.Api\Pages\TestAutomation.cs:line 52
   at Microsoft.PowerApps.TestAutomation.Tests.TestAutomation.RunTestAutomation() in C:\agent\_work\4\s\test\sdk\PowerAppsTestAutomation\Microsoft.PowerApps.TestAutomation.Tests\TestAutomation\RunTestAutomation.cs:line 68


Sources

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

Source: Stack Overflow

Solution Source