Applies to CrossBrowserTesting SaaS, last modified on January 19, 2022

CircleCI is a continuous integration tool that lets you automate your development process quickly, safely, and at scale. Through CircleCI's integration with GitHub, GitHub Enterprise, and Bitbucket, 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 CircleCI with GitHub for testing using the Selenium WebDriver and Python programming language.

Set up CircleCI

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

    Create repository

    Click the image to enlarge it.

  2. Add file tests/ and be sure to add your username and authkey.


    import unittest
    from selenium import webdriver
    import requests
    from import expected_conditions as EC
    from import By
    from import WebDriverWait

    class LoginForm(unittest.TestCase):
        def setUp(self):

            # Put your username and authkey below
            # You can find your authkey at
            self.username = "YOUR_USERNAME"
            self.authkey = "YOUR_AUTHKEY"

            self.api_session = requests.Session()
            self.api_session.auth = (self.username,self.authkey)

            self.test_result = None

            caps = {}

            caps['name'] = 'Screenshot Example'
            caps['browserName'] = 'Chrome'
            caps['version'] = '71x64'
            caps['platform'] = 'Windows 10'
            caps['screenResolution'] = '1366x768'

            self.driver = webdriver.Remote(


        def test_CBT(self):

                self.driver.find_element_by_css_selector('body > div > div > div > div > form > div.form-actions > button').click()

                elem = WebDriverWait(self.driver, 10).until(
                    EC.presence_of_element_located((By.XPATH, '//*[@id=\"logged-in-message\"]/h2'))

                welcomeText = elem.text
                self.assertEqual("Welcome", welcomeText)

                print("Taking snapshot")
                snapshot_hash ='' + self.driver.session_id + '/snapshots').json()['hash']

                self.test_result = 'pass'

            except AssertionError as e:
                # log the error message, and set the score to "during tearDown()".
                self.api_session.put('' + self.driver.session_id + '/snapshots/' + snapshot_hash,
                    data={'description':"AssertionError: " + str(e)})
                self.test_result = 'fail'

        def tearDown(self):
            print("Done with session %s" % self.driver.session_id)
            # Here we make the api call to set the test's score.
            # Pass it it passes, fail if an assertion fails, unset if the test didn't finish
            if self.test_result is not None:
                self.api_session.put('' + self.driver.session_id,
                    data={'action':'set_score', 'score':self.test_result})

    if __name__ == '__main__':

  3. Add file .circleci/config.yml to the new repository.


    version: 2
          - image: circleci/python:jessie-node-browsers
          - checkout
          - run: mkdir test-reports
          - run: sudo pip install selenium
          - run: sudo pip install requests
          - run:
              command: python tests/

Run your build on CircleCI

  1. From the CircleCI Dashboard, after selecting the Add Projects tab, click the Set Up Project button next to your desired repository.

    Set up project

    Click the image to enlarge it.

  2. Scroll to the bottom of the page and click the Start Building button.

    Start building button

    Click the image to enlarge it.

You should see your build start to run in CircleCI and in the CrossBrowserTesting app here.

If you have any questions or concerns, feel free to get in touch.

See Also

Continuous Integration
Travis CI
GitHub Actions

Highlight search results