'Selenium test cases get stuck in build agents. How to resolve?

We are running 200 - 300 UI test cases from an Azure pipeline. All the test cases are running on self hosted Windows agents, where all the dependencies are installed. Chrome browser, vstest, etc.

Issue is when we use parallelism multi agent from Azure pipeline, the pipeline runs for a long time without throwing an issue. Sometimes browser is getting stuck while cases are running. Sometime no response status appears in the pipeline logs. We are using 32bit, 8cpus machine.

Please suggest the best method to overcome this problem.



Solution 1:[1]

Selenium test cases get stuck in build agents. How to resolve?

You need to analyze why the UI test is stuck. You can share the logs that you think are problematic in your question. Personal experience for this issue is generally because the mode of the private agent is not set correctly.

When we create the private agent, we could set two modes Interactive vs. service. If we set the agent as service for the UI test, the build/test will be blocked. Since the tested UI interface cannot pop up in this mode. We need to generate the private agent as Interactive mode:

Interactive vs. service

You can run your self-hosted agent as either a service or an interactive process. After you've configured the agent, we recommend you first try it in interactive mode to make sure it works. Then, for production use, we recommend you run the agent in one of the following modes so that it reliably remains in a running state. These modes also ensure that the agent starts automatically if the machine is restarted.

As a service. You can leverage the service manager of the operating system to manage the lifecycle of the agent. In addition, the experience for auto-upgrading the agent is better when it is run as a service.

As an interactive process with auto-logon enabled. In some cases, you might need to run the agent interactively for production use - such as to run UI tests. When the agent is configured to run in this mode, the screen saver is also disabled. Some domain policies may prevent you from enabling auto-logon or disabling the screen saver. In such cases, you may need to seek an exemption from the domain policy, or run the agent on a workgroup computer where the domain policies do not apply.

Sources

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

Source: Stack Overflow

Solution Source
Solution 1 Leo Liu-MSFT