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.