For this document, we provide complete example files in our Azure Pipelines GitHub Repository.
Azure Pipelines is a continuous integration tool that lets you automate your development process quickly, safely, and at scale. Through Azure Pipelines’ integration with GitHub, GitHub Enterprise, Azure Repos Git & TFVC, Bitbucket Cloud, and Subversion, every time you commit code, a build is created and automatically run in a clean container or virtual machine, allowing you to test every commit.
In this guide we will use Azure Pipelines for testing using the Selenium WebDriver and Python programming language.
Set up Azure Pipelines
-
Sign into your Azure DevOps organization or follow the detailed guide to create a new one.
-
Install the CBT for Azure DevOps extension for your organization
-
Navigate to your GitHub account and create a new repository.
-
Add file test_selenium.py.
Python
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
import os, time
username = os.getenv("CBT_USERNAME")
authkey = os.getenv("CBT_AUTHKEY")
caps = {
'platform': 'Windows',
'browserName': 'Chrome',
}
driver = webdriver.Remote(
command_executor="http://%s:%[email protected]/wd/hub"%(username, authkey),
desired_capabilities=caps)
driver.get("http://www.google.com")
if not "Google" in driver.title:
raise Exception("Unable to load google page!")
elem = driver.find_element_by_name("q")
elem.send_keys("CrossBrowserTesting")
elem.submit()
print(driver.title)
driver.quit() -
Add file requirements.txt
requests==2.22.0
selenium==3.141.0
Build Your Pipeline
-
From the Azure DevOps Dashboard, create a new project and select Pipelines.
-
Create a new pipeline and set up your GitHub repo.
-
Add a new Service Connection from the Project Settings page using the type CBT Credentials
-
Add the CrossBrowserTesting Configuration task to your azure-pipelines.yml file
-
Save and Run.
You should see your build start to run in Azure Pipelines and in the CrossBrowserTesting app.
Conclusions
By following the steps outlined in this guide, you are now able to seamlessly integrate Azure Pipelines and CrossBrowserTesting. If you have any questions or concerns, please feel free to reach out to our Support team.