UI testing is an essential component in a Software Development lifecycle and Selenium is one of the tools that help you achieve that. In this post, we will talk about triggering your selenium scripts through Azure DevOps and how you can make your UI tests part of your release pipeline.
This blog post will mostly focus on triggering Maven Selenium tests through Azure DevOps on VMs either hosted on-prem or on Azure but self-hosted NOT Microsoft hosted.
Headless Selenium vs Interactive
The Chrome and Firefox drivers for selenium provide you with an opportunity to run your UI tests without needing an interactive browser to open up, that is called headless testing. Some of the advantages of headless selenium are:
- Easier to setup, since can run anywhere (do not need a browser to open up).
- Faster and more reliable since interactive tests can get interrupted and cause the tests to fail.
Setting up the agent for Selenium tests
Setting up the agent on the machine where the tests will run will depend on what type of testing you are doing, headless or interactive. If it is a headless setup, you can set up the Azure DevOps agent to run on the Virtual machine (on-prem or Azure) as a service, requiring very low maintenance. But if you are running your tests in an interactive fashion, then the agent will need to be setup as an interactive agent that runs under a user account that has auto-logon enabled. More on that can be found here: Configure for UI testing – Azure Pipelines | Microsoft Docs
If the Azure DevOps agent is set to run interactively under a user account, screensaver will need to be disabled for that user. Also any accidental log-off of that user will cause the agent to appear offline. As you can see, this is the level of high maintenance that interactive selenium tests require.
Adding Selenium Tests to your release pipeline
If you have a release pipeline that deploys your application, adding your UI tests into that pipeline will ensure that you are getting the expected results and most importantly that the application is up after the deployment. The pipeline will fail the UI tests fail adding a layer to ensure quality.
If you are using the classic release and not YAML. You can add an agent job that either runs a powershell script or a maven task to trigger the tests.
If the UI test is an interactive test, a browser will open up and run the test and if successful, send a success message back and you are now more confident in your release pipeline and it can take you to the next step in your DevOps journey.
If you need help in setting up your release pipeline or automating your selenium tests, reach out to us at the Microsoft Business Group and we can help assess your DevOps state and help you get on with your DevOps journey.