Thursday, September 17, 2020

Fix "unknown error: cannot find Chrome binary" Failure in UI Test Execution Using Test Clients in Azure DevOps Pipelines.

 This blog explains one of the issues faced by Test Automation team when executing the UI test scripts using Chrome web driver. Lets have a look at, what is the process Test Automation team followed and the issue encountered. Importantly let's see how it can be resolved. 

In the UI test scripts developed with Spec flow, Selenium and C#, the purpose is to run automated UI test using a CD pipeline. Team has setup a Azure DevOps agent to run in interactive mode and installed the chrome web browser in the agent VM. Once, pipelines are  executing the UI test automation using the test agent it has reported the following error.


System.AggregateException : One or more errors occurred. (unknown error: cannot find Chrome binary) (unknown error: cannot find Chrome binary)

---- OpenQA.Selenium.WebDriverException : unknown error: cannot find Chrome binary

---- OpenQA.Selenium.WebDriverException : unknown error: cannot find Chrome binary

By looking at the error message, we assumed this issue is due to Azure DevOps, interactive user executing the test in the test agent, couldn't find the chrome browser installed in the agent machine. However, we have already installed the chrome in the agent machine. 

First we checked the agent configuration process to verify the agent and chrome browser , both configured using the same user and chrome is accessible by the test agent user. We identified that the test agent user can run the Chrome browser manually using the shortcut. However, if we open up the command prompt and type Chrome.exe , it is reporting "Chrome is not recognized as an internal or external command, operable program or batch file". This finding leads to an assumption, the same should have been happening while executing the test scripts. If Chrome.exe is tried in the command prompt from the Chrome installation path, it works fine and opens up a Chrome browser.

With this knowledge, we added the chrome path as the environment variable and restarted the machine. Once, test are executed from the pipelines after setting the path environment variable with the Chrome.exe path, the agent was able to execute the test without any issues. So, it is confirmed the reason for this issue was Chrome.exe could not be located by the user, interactively executing tests in the agent. 

No comments:

Post a Comment