How to run a Selenium PyTest job in a hosted Azure Devops Agent

Michiel Thai
1 min readNov 22, 2020

--

Here are some quick YAML pipeline you can use to run different Selenium PyTest using a generic Pipeline in a hosted Azure Pipelines Agent.

Hosted Agents are normally equiped with the latest Firefox/Chrome browser and their respective webdriver.

The sample pytest

create two 2 files in a folder:

  1. conftest.py

2. test_login.py

3. azure-pipelines.yml

The first task is to ping the url to see if it resolves. Then it will update the buildid with the test base url. This can be handy if you are using the same pipeline to run different tests.

The second task basicly runs a pytest command. It can take a list of Markers and pass it to the command. To follow this example, the base_url, username and password are fetched from the Pipeline variables and passed as pytest cli arguments as well.

--

--

Michiel Thai

A Systems Engineer that loves to develop, mainly using PowerShell. Certified Azure Devops Expert.