Azure Pipelines

Applies to CrossBrowserTesting SaaS, last modified on January 10, 2023

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

  1. Sign into your Azure DevOps organization or follow the detailed guide to create a new one.

  2. Install the CBT for Azure DevOps extension for your organization

  3. Navigate to your GitHub account and create a new repository.

    Creating new repository

    Click the image to enlarge it.

  4. 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()

  5. Add file requirements.txt

    requests==2.22.0
    selenium==3.141.0

Build Your Pipeline

  1. From the Azure DevOps Dashboard, create a new project and select Pipelines.

    Azure DevOps Dashboard

    Click the image to enlarge it.

  2. Create a new pipeline and set up your GitHub repo.

    Creating pipeline

    Click the image to enlarge it.

    Setting up a repository

    Click the image to enlarge it.

  3. Add a new Service Connection from the Project Settings page using the type CBT Credentials

    Adding service connection

    Click the image to enlarge it.

  4. Add the CrossBrowserTesting Configuration task to your azure-pipelines.yml file

    Adding configuration task

    Click the image to enlarge it.

    Adding configuration task

    Click the image to enlarge it.

  5. 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.

See Also

Continuous Integration
Travis CI
GitHub Actions
CircleCI

Highlight search results